开发者

Spinner, Onitemselected, Layout

How can I change the main layout to another when using a spinner so each item in the spinner will change to a new layout when item is selected开发者_StackOverflow社区.


There are several ways you could approach this.

If there are just a few different layouts, you could use a FrameLayout to hold the different layouts and switch by setting the visibilities to the one you want to show. This is also most likely the easiest approach.

If you have many layouts to switch between you could inflate the layouts on demand and then addView and removeView to change between them. This will keep your app from having large layouts, and we have all been drilled on the importance of keeping our layouts under control for performance reasons.

Finally you could consider using different activities and switching between them, duplicating the spinner control in each activities layout.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜