Question

I have GridView and I want to be able to switch between adapters.

Context:

I have data from two separate sources and I want to be able to easily switch between those.

Is it possible to just switch adapters or there is other solution?

Was it helpful?

Solution

You should be able to call setAdapter on lists or grids (or any AdapterView) multiple times. One caveat: On ListViews, you can't call addHeaderView or addFooterView once you've made a setAdapter call. Alternatively, if it's giving you a hard time just put two GridViews in a ViewSwitcher (or FrameLayout) with each set to one of the adapters you want and show/hide one or the other when you need to, rather than swapping out sources on one GridView.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top