OK, so I have a broadcast receiver get called and in the onReceive()
method I update a gallery with a new adapter using static data, all done on the UI thread.
However, nothing changes. The old data is left in the gallery, but when I debug my code and take my time it updates after invalidate is called. Oh, BTW, the view is in a ViewFlipper, but I change to the proper view before creating the new adapter. So I have a race condition, is this normal? If it isn't, what should I do?
Below is a sample of what I'm talking about in the onRecieve()
.
onRecieve() {
mFlipper.setDisplayedChild(0);
mNavAdapter.addCategory(-1);
mGalNav.setSelection(0);
getCategoryProducts(-1);
}
void getCategoryProducts(int category) {
mGalProducts.setAdapter(new DealCheckInAdapter(this,
getCheckInProducts()));
mGalProducts.invalidate();
}
The invalidate()
method is not supposed to do what I'm guessing you thinking it will do. You suppose to use:
mDealCheckInAdapter.notifyDataSetChanged();
This is the method which "refreshing" the listView adapter.