0

I'd like to change my listView items dynamically. The algorithm goes like this:

1.I create the default view for my listView using adapter and show it to user. The list item contains Imageview, textview and another imageview which is invisible. 2.The data is beeing dowloaded in the meantime. 3. after my data is downloaded, I'd like to check whether my listview contains any of downloaded items. If yes, I want to make visible the previously invisible ImageView for this item.

Should I add some kind of method to my adapter, call it and then call invalidateViews(), notifyDataSetChanged(), or notifyDataSetInvalidated()? Or maybe there is some kind of standard way to find my adapter's item by Id or sth and then make visible the imageview for this item?

This list update operation is the only one left to implement for me.

sliwkacz
  • 387
  • 2
  • 4
  • 18

2 Answers2

1

Read the Displaying Bitmaps Efficiently introduction and in particular the part about Handle Concurrency. This will give you all the information you need.

Baschi
  • 1,128
  • 11
  • 14
1

Should I add some kind of method to my adapter, call it and then call invalidateViews(), notifyDataSetChanged(), or notifyDataSetInvalidated()?

Yes, exactly.

maybe there is some kind of standard way to find my adapter's item by Id or sth and then make visible the imageview for this item?

Above mentioned way is enough. There is no such standard or special way to do it AFAIK.

Braj
  • 2,164
  • 2
  • 26
  • 44
  • Bu how can I inform my adapter that this particular item should show the previously invisible ImageView? I'm comparing two items' IDs. If they're the same, I'd like to start the showing ImageView proces. – sliwkacz Dec 10 '13 at 14:38
  • Have a look at below links and come up with ur implementation http://stackoverflow.com/questions/10354692/how-to-refresh-listview-dynamically http://stackoverflow.com/questions/5320358/update-listview-dynamically-with-adapter http://stackoverflow.com/questions/16818984/android-issue-updating-listview-dynamically-based-off-sockets http://stackoverflow.com/questions/17941054/android-dynamically-updating-a-custom-listview-after-items-in-an-arraylist-are – Braj Dec 11 '13 at 06:19