android - notifyDataSetChanged example -


i'm trying use in android application notifydatasetchanged() method arrayadapter doesn't work me.

i found as answer here, notifydatasetchanged() should run in main thread, there no example that.

could send example or @ least link?!

for arrayadapter, notifydatasetchanged works if use add(), insert(), remove(), , clear() on adapter.

when arrayadapter constructed, holds reference list passed in. if pass in list member of activity, , change activity member later, arrayadapter still holding reference original list. adapter not know changed list in activity.

your choices are:

  1. use functions of arrayadapter modify underlying list (add(), insert(), remove(), clear(), etc.)
  2. re-create arrayadapter new list data. (uses lot of resources , garbage collection.)
  3. create own class derived baseadapter , listadapter allows changing of underlying list data structure.
  4. use notifydatasetchanged() every time list updated. call on ui-thread, use runonuithread() of activity. then, notifydatasetchanged() work.

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -