Updating the contents of a MergeAdapter
I have a pretty nifty MergeAdapter that contains a bunch of custom views and some custom ListAdapters. This MergeAdapter drives a ListActivity that displays content that get's updated every x seconds.
Currently I just create a new MergeAdapter, create and add all of my custom views (and this includes a few ImageViews) - and call setAdapter on the ListView in my activity.
After about 10 minutes of updates I run out of heap space and crash.
Ultimately because a new ImageView is added, and the following exception is thrown:
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
With simpler adapters (like ArrayAdapter), I would just update the data set, and call
noti开发者_如何学运维fyDataSetChanged()
on the adapter.
Is there a similar/recommended approach for "updating" a MergeAdapter? Or should I be walking the contents of a potentially complex MergeAdapter and updating individual Views?
Is there a similar/recommended approach for "updating" a MergeAdapter?
notifyDataSetChanged()
works, AFAIK. The current MergeAdapter
has the code to ripple any changes from ListAdapters
inside it to whatever has registered interests in changes in the MergeAdapter
. This probably has not been tested enough, so if you have a sample app that demonstrates otherwise, post a link to it or send it to me (mention this SO question).
精彩评论