I have added a spinner to my ActionBar using the second option from the answer here .
How to I add a spinner adapter to the spinner? I tried using a Spinner object as Google describes here but get a null Spinner object.
Anybody know how to do this? I don't want the spinner to be in the navigation area of the action bar but in with the other action items (I am using the split action bar).
Thanks for the help!
I know this is an old question, but just in case someone stumbles on it (as I did) and still looks for a complete answer, here is how to do it using the compatibility library, so that it works from to v7 (Android 2.1 Eclair) to current v19 (Android 4.4 KitKat):
In menu_layout.xml:
Using
http://schemas.android.com/apk/res-auto
namespace aliased asyourapp
enables you to use the attributes showAsAction and actionViewClass that do not exist on older versions of Android.Then in your Activity code:
Et voilà!
Well, I ditched the Spinner idea for using a submenu. I realized that the spinner was for selecting things that stayed selected; submenus seamed to be a better UI fit.
Thanks anyways.
P.S. I am new here. If answering my own question is annoying to the community please let me know. I want to be a good citizen. I have gotten a lot of help from you all already.
I know you ditched the spinner, but I'll give some hints here in case other people is having the same problem or you come to develop the same pattern in a different app
then in the
OnCreateOptionsMenu
you do:happy coding...