Overflow menu not showing in Android 4.2.2

enter image description here

I am following a simple tutorial. The problem is that it does not show the overflow menu in Android 4.2.2. And if I press the hardware menu button, you will see the menus listed.

xml code:

<item android:id="@+id/add_item" android:icon="@drawable/ic_action_emo_laugh" android:showAsAction="ifRoom" android:title="Emo Laugh" > </item> <item android:id="@+id/about" android:icon="@drawable/ic_action_emo_tongue" android:showAsAction="never" android:title="Emo TOngue" > </item> 

+4
source share
1 answer

@TalhaMir to the right. If you want to be sure that the overflow menu is always visible, you can use this workaround

 <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/capture" android:icon="@drawable/ic_action_capture" android:showAsAction="always"/> <item android:id="@+id/location" android:icon="@drawable/ic_action_location" android:showAsAction="always"/> <item android:showAsAction="always" android:icon="@drawable/abs__ic_menu_moreoverflow_holo_dark"> <menu> <item android:id="@+id/terms_of_service" android:title="@string/ab_terms_of_service"/> <item android:id="@+id/privacy_policy" android:title="@string/ab_privacy_policy"/> <item android:id="@+id/help" android:title="@string/ab_help"/> </menu> </item> </menu> 

or you can use this hack in the onCreate method of your Application class

 private void getOverflowMenu() { try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if(menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception e) { e.printStackTrace(); } } 

But this hack breaks compatibility and, as I know, does not work with Action Bar Sherlock

+4
source

All Articles