Basically, I got one activity has two layouts, one is gridview, which has mBaseAdapter as its adapter.
the other one is gallery, which has galleryBaseAdapter as its adapter. The elements in both of layouts are initialized in the onCreate function.
I have a menu item to switch layout, but when I switched, it seems the adapter is not updating.
I have called the data changed notifier, but still won’t work.
Here is a snippet of code:
if (mIsGridView) {
mIsGridView = false;
Main.this.setContentView(R.layout.gallary_view);
updateGalleryNotifer();
} else {
mIsGridView = true;
Main.this.setContentView(R.layout.view_table_layout);
updateBaseViewNotifer();
}
Thanks for any helpful suggestion.
About this problem, I found the solution by my own.
The answer is: after you switch the layout, you need to reinitialize your elements for the corresponding gridview, gallery, or buttons. If you didn’t do that, nothing will take effect.