Catching spinner item click when there is only one item listed

丶灬走出姿态 提交于 2019-12-11 16:28:02

问题


I'm trying to do something which wasn't the spinner specially made for. I got list that changes dynamically. I need to catch onSelectedItemClick when the user choses the item. Problem occurs when there is only one item in the spinner adapter. Selecting it (or rather reselecting, since it was selected already) won't fire OnSelectedItemListener.

How could I catch it otherwise?


回答1:


if you have only one item then no need to choose from spinner and you can get in onSeletedItem method.

  • If you have only one item, then onItemSelected is also called.

String str = (String)parent.getSeletedItem();



来源:https://stackoverflow.com/questions/11250529/catching-spinner-item-click-when-there-is-only-one-item-listed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!