Hi,

I have an adapter class composed of several child adapters. Looks like
this:

  public class TestAdapter extends BaseAdapter {

    ArrayLIst<Adapter> mChildAdapters;

    public void addAdapterChild(Adapter adapter) {
      mChildAdapters.add(adapter);
    }
  }

it works ok, running into a problem though if one of the child
adapters calls notifyDataSetChanged(). It looks like the notification
is never brought upwards to TestAdapter. For example, my child adapter
has a thumbnail image in each row, and I download them asynchronously.
When the image download is complete, the adapter will call
notifyDataSetChanged() so that the view is refreshed and the thumbnail
is shown. Works fine stand-alone.

When in this parent adapter, no refresh occurs. I can do this to fix
it, but am worried about an infinite cycle of updates:

  public void addAdapterChild(Adapter adapter) {
    mChildAdapters.add(adapter);

    adapter.registerDataSetObserver(mDataSetObserver);
  }

  private DataSetObserver mDataSetObserver = new DataSetObserver() {
    @Override
    public void onChanged() {
      notifyDataSetChanged();
    }
  };

so as long as this parent adapter is the one that calls
notifyDataSetChanged(), the refresh occurs and the thumbnails are
shown.

Thanks,
Mark

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to