views:

19

answers:

1

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?

A: 

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.

Yoni Samlan
Thanks for your answer - it turned out that switching adapters works a lot better and with less overhead than `ViewSwitcher`.
pixel