How do you retrieve the array adapter currently set for a spinner? Android OS, Droid

巧了我就是萌 提交于 2019-12-24 02:19:14

问题


Looking to create a menu toggle that switches between two possible arrays for a spinner. For example, if the spinner is set to show array A, then when I press this menu button, I want the spinner to be set to array B. If I press it again, I want it to be set back to array A.

I can handle the if/then statements and all, but how do I call the spinner's array adapter? I know how to call its value using getSelectedItemPosition(); but is there a similar method for retrieving WHICH array it is currently set to?


回答1:


I think AdapterView#getAdapter() is inherited by android.widget.Spinner?




回答2:


What you're seeing is that AdapterView#getAdapter() is an abstract method. You want to be using AbsSpinner#getAdapter() which is where getAdapter() is actually implemented. This will return a SpinnerAdapter.



来源:https://stackoverflow.com/questions/2306955/how-do-you-retrieve-the-array-adapter-currently-set-for-a-spinner-android-os-d

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