开发者

Trying to alternate between GridView & ListView leaving artifacts

开发者 https://www.devze.com 2023-02-08 03:50 出处:网络
I have an app whose default style is to present data in a GridView. When the user presses the Menu button they can choose to present the data as a ListView.

I have an app whose default style is to present data in a GridView. When the user presses the Menu button they can choose to present the data as a ListView.

The problem is that once the first switch happens, it's as though the ListView is simply superimposed above the GridView. The GridView layout doesn't go away. I have to scroll with my finger a little bit before it disappears.

What I'm doing is basically setting another setContentView call to m开发者_JAVA百科y XML file that defines the ListView. It's not just a simple matter of changing the adapters.

I am guessing that I need to completely destroy or remove my GridView--but how do I do this? Note that if I switch from ListView to GridView the problem remains.


Consider putting both in a ViewFlipper, rather than using setContentView().


for list

gridview.setNumColumns(1);

and for grid

gridview.setNumColumns(2);


What about playing with visibility? When List is selected in menu, make gridview visibility to 'GONE',and list to 'VISIBLE' and vice versa when Grid is selected in menu

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号