3

Based on the question How can I update a single row in a ListView? I want to update all the visible rows beside the one that I'm changing in the moment. I can take any row that I want with listView.getChildAt(index) but I don't know how can I compare the the returned view with another view that I already have. Their Ids are based on the view definition in the XML file so All the rows have the same Id.

Any help is welcome, thanks in advance.

Community
  • 1
  • 1
Jp_
  • 5,973
  • 4
  • 25
  • 36

1 Answers1

0

That question was for a very specific case. If you want to update all rows, then

  1. Only the rows "visually on the screen now" are actual children views of the ListView. It wouldn't even make sense to want to update the others.
  2. Doing it individually for each child view would be, in fact, a very roundabout way of refreshing the whole ListView.

Just change the Adapter's backing data and then call notifyDataSetChanged() on it. It will refresh all visible items (calling getView() for each one), and as you scroll the new ones will be shown as updated too.

matiash
  • 54,791
  • 16
  • 125
  • 154
  • Thank you for the answer. I actually figured it out a bit later creating a new data structure inside the adapter class to update what I needed. I couldn't use getChildAt(index) because I needed to update invisible rows as well so I just used adapter.getCount(). I stored in the TAG to know which row I had to skip. And finally I couldn't use notifyDataSetChanged() because I was using a seekBar so it would drop my "clicking" every time it would be called. – Jp_ Jul 08 '14 at 08:58