question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Top card doesn't change on NotifyDataSetChanges

See original GitHub issue

I am using an arraylist in my adapter as the data source for the cards. On a button toggle, I have to change the cards displayed. Hence I call the clear() function of my array and then do an addAll() with the required data. Followed by a call to the adapters notifyDataSetChanged()

The data does change but the first card is the same as what i saw before the button toggle. on swiping away this card I see that the next card is the second card of my second list(and same for the 3rd,4th etc hence I conclude the data has changed). But why didn’t the first card refresh to show the new list?

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
hunterTRcommented, Mar 10, 2015

I solved this by using flingContainer.removeAllViewsInLayout();

2reactions
tobiasschuergcommented, Mar 4, 2016

+1 for flingContainer.removeAllViewsInLayout();

Read more comments on GitHub >

github_iconTop Results From Across the Web

RecyclerView scrolls to top on notifyDataSetChanged in chat ...
This is my way to avoid scrollview move to top Instead of using notifyDataSetChanged() , I use notifyItemRangeChanged();
Read more >
Updating data in an Android RecyclerView - Suragch - Medium
Replace old list with new list ... Clear the old list then add a new one. ... adapter.notifyDataSetChanged();. The adapter has a reference...
Read more >
RecyclerView notifyItemChanged Prevent Scroll [37087322]
Hi! Have a trouble with RecyclerView after support library 23.2.1 release. This method below is inside my custom RecyclerView.Adapter.
Read more >
NotifyDataSetChanged: Invalidating All RecyclerView Data
The RecyclerView adapter's onNotifyDataSetChanged method does not specify what about the data set has changed, forcing any observers to assume that all ...
Read more >
Calling NotifyAll to Update RecyclerView from External Method
You can add a function in the Adapter of your RecyclerView (e.g. UpDateData ) and call NotifyDataSetChanged in your Adapter . public void ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found