开发者

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

开发者 https://www.devze.com 2022-12-21 06:38 出处:网络
Looking to create a menu toggle that switches between two possi开发者_JAVA技巧ble arrays for a spinner. For example, if the spinner is set to show array A, then when I press this menu button, I want t

Looking to create a menu toggle that switches between two possi开发者_JAVA技巧ble 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?


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


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.

0

精彩评论

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

关注公众号