android spinner - how do I remove the current selection?

耗尽温柔 提交于 2020-12-13 11:19:32

问题


I have some dependencies between my spinners and it happens, that a spinner becomes empty.

The problem now is, that I don't know how to clear the spinner, I'm adopting the data of the adapter, notify the adapter and if I click the spinner, there are no values in there, but the spinner's selected item is NOT cleared and still is displayed...


回答1:


I'm not sure what you want, but to delete all itens in your spinner you can set the adapter null, like this:

mySpinner.setAdapter(null);

and if you want to remove a specific item, then you should remove it from your adapter and set your spinner again

mySpinner.setAdapter(myAdapter);


来源:https://stackoverflow.com/questions/16901271/android-spinner-how-do-i-remove-the-current-selection

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