How to call notifyDataSetChanged() for only one element of gallery? Default call update evrything, which is quite resourse expencieve and unnecessary. I want solution, which works fro API 8.
Asked
Active
Viewed 106 times
1 Answers
1
To do that you need to find the row view that you want to refresh and make the refresh manually. Something like this:
private void updateSingleView(int i) {
View viewToUpdate = listview.getChildAt(i - listview.getFirstVisiblePosition());
//Do whatever update you need to do
viewToUpdate.invalidate(); //Or postInvalidate() if you call it from a non Ui thread.
}
Found by this SO question.
-
-
@user1551603 I suggest you move from `Gallery` to `ViewPager` since it is depracated from API 16 and up. You can use the android compatibility library to use the `ViewPager` in API 8 that you need. Link: http://developer.android.com/reference/android/widget/Gallery.html – AggelosK Jul 25 '13 at 08:50
-
-
1@user1551603 You are right it requires quite a lot changes in your code but this way you futureproof your app and also I do not think what you ask is possible in Gallery (at least i do not know a way of achieving this to be frank:) ). – AggelosK Jul 25 '13 at 09:15