In my android app I have a menu option which works when the device has dedicated hardware menu option. for another device I don't have dedicated Menu button so I tried to add a button and on click of that a popup will display the menu, The popup is working but not displaying the options, and further to that how to work on the selected popup option.
My button layout is as follows:
<ImageButton
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_overflow_holo_dark"
android:contentDescription="@string/descr_overflow_button"
android:onClick="showPopup" />
This is my code to show the popup:
public boolean showPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.emailmenu, popup.getMenu());
popup.show();
return true;
}
And this my option
code:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/bluebutton" android:icon="@drawable/icon_blue_btn"
android:title="" />
<item android:id="@+id/zephyr" android:icon="@drawable/icon_zephyrme"
android:title="" />
<item android:id="@+id/skype" android:icon="@drawable/icon_skype"
android:title="" />
</menu>
I all ready have this onCreateOptionsMenu() for triggering the option from dedicated menu key. How to get it to work from popup.