开发者

Android: Use spinner in a sub tab

开发者 https://www.devze.com 2023-01-17 07:21 出处:网络
I\'m trying to put a spinner in a sub-tab in my android app.Touching the spinner causes a crash. Searching seems to suggest that for some reason it is not possible to use spinners in sub-tabs, but th

I'm trying to put a spinner in a sub-tab in my android app. Touching the spinner causes a crash.

Searching seems to suggest that for some reason it is not possible to use spinners in sub-tabs, but this seems silly to me. I've also tried using activity 开发者_StackOverflowgroups as an alternative to sub-tabs, but I get the same crash.

Has anyone resolved this?


I'm not really sure about this, but try initializing your Spinner in Java code with the context of the parent Activity, like

Spinner spinner = new Spinner(isChild() ? getParent() : this);
0

精彩评论

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

关注公众号