I have a menu that lives in the action bar:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:asam="http://schemas.android.com/apk/res-auto"
>
...
<item android:id="@+id/map_types_item"
android:title="@string/map_menu_map_type_text"
asam:showAsAction="always"
android:icon="@drawable/ic_action_bar_map"
android:menuCategory="system"
android:orderInCategory="300">
<menu android:id="@+id/map_types_menu">
<group android:checkableBehavior="single">
<item android:id="@+id/map_type_normal"
android:title="@string/map_type_normal_text"
/>
<item android:id="@+id/map_type_satellite"
android:title="@string/map_type_satellite_text"
/>
<item android:id="@+id/map_type_hybrid"
android:title="@string/map_type_hybrid_text"
/>
</group>
</menu>
</item>
</menu>
And I would like to programitcally click that button such that the menu opens in the action bar.
Is that possible?
Tried:
mapTypeMenu = menu.findItem(R.id.map_types_item);
OR
mapTypeMenu = menu.findItem(R.id.map_types_menu);
Only R.id.map_types_item
is found.
Then to programmatically open:
onOptionsItemSelected(mapTypeMenuItem);
Is this possible? If so what am I doing wrong?
EDIT:
This image shows my action bar. The map icon it the one I am programmatically trying to click:
This image shows what it looks like when clicked from the UI. I would like to open that programmatically as well: