Question

I have a ListView which onItemClick selected item changes its layout, pops different buttons. If any other item is selected, the previous selected one returns to normal. My ListView adapter works fine but refreshing the whole list with notifyDataSetChanged() in my adapter takes too much time.

My problem is to refresh only the changed items in the ListView. And also I would like to have suggestions for better scrolling performance.

Was it helpful?

Solution

try to implement View Holder Pattern it increases the performance of loading and scrolling of ListViews

Making ListView Scrolling Smooth | Android Developers
Using lists in Android (ListView) - Tutorial - Vogella

from the docs:

Your code might call findViewById() frequently during the scrolling of ListView, which can slow down performance. Even when the Adapter returns an inflated view for recycling, you still need to look up the elements and update them. A way around repeated use of findViewById() is to use the "view holder" design pattern.

OTHER TIPS

you can define one method in adapter class which will return current item view. in onitemclick use this method to make changes in clicked item. You can define class view type class variable in activity and store previous view there...

ListView scrolling performance slows down when widgests like textviews, images are at the bottom of the layout hierarchy.

So for improving list performance one should design item xmls with minimum layout tree levels.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top