Closed chrisjenx closed 11 years ago
Thanks for reporting and offering a solution. I pushed a fix. Does it work for you?
My setAdapter
is different, but yours does effectively the same thing.
@Override
public void setAdapter(ListAdapter adapter) {
if (mAdapter != null && mDataSetObserver != null) {
mAdapter.unregisterDataSetObserver(mDataSetObserver);
}
if (BuildConfig.DEBUG && adapter != null) { // assert adapter in debug mode
if (!(adapter instanceof PinnedSectionListAdapter))
throw new IllegalArgumentException("Does your adapter implement PinnedSectionListAdapter?");
if (adapter.getViewTypeCount() < 2)
throw new IllegalArgumentException("Does your adapter handle at least two types of views - items and sections?");
}
destroyPinnedShadow();
super.setAdapter(adapter);
if (adapter != null) {
mAdapter = adapter;
mDataSetObserver = new AdapterDataSetObserver();
mAdapter.registerDataSetObserver(mDataSetObserver);
}
}
This follows how the current ListView
impliments the observer
I added the data set observer in my code.
But if you change the dataset after the adpater has been attached, then the listview does not recreate the pinned view.
If you need the code I can do a pull request later.
Something like:
worked a charm for me