Reputation: 1893
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.
Upvotes: 1
Views: 2112
Reputation: 6736
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 ofListView
, 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 offindViewById()
is to use the "view holder" design pattern.
Upvotes: 1
Reputation: 46
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.
Upvotes: 1
Reputation: 3488
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...
Upvotes: 1