I made a drop-down item on an Action bar just as said here How to add a Dropdown item on the action bar so I have a menu.xml with
<item
android:id="@+id/menuSpinner"
android:showAsAction="ifRoom"
android:actionLayout="@layout/options" />
and options.xml
<?xml version="1.0" encoding="utf-8"?>
<Spinner xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/my_array" />
and array in strings.xml
<string-array name="my_array">
<item>ONE</item>
<item>TWO</item>
<item>THREE</item>
</string-array>
Everything looks fine in Activity.
Please, help, how should I get onClick message, or just how I may know what item is selected (visible) on Action Bar. May be something in this code..?
if (item.getItemId() == R.id.menuSpinner) {
...
}
UPD: by now I did this
Put an id to my spinner in options.xml
in code wrote this
Spinner sp = (Spinner) findViewById(R.id.spinner_menu);
if (sp.getSelectedItemId()==0) {
...
}
this is suits to mi because I do not need to act immediatly to user spinner clicks.