How do I show Overflow Menu Items to Action Bar in Android
android, android-actionbar
Solution
To show three dot icon, to Action Bar, just use below method in your OnCreate():
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();
}
}
Problem
I am writing an Android App in which i am trying to show Overflow Menu Items to ActionBar using this great tutorial link: http://wptrafficanalyzer.in/blog/adding-action-items-and-overflow-menu-items-to-action-bar-in-android/ Problem: ``` Not getting Overflow Menu Items (Icon) ``` Please see below Screen Shot for more clarity: Manifest.xml: ``` <uses-sdk android:minSdkVersion="14" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".MainActivity" android:label="@string/app_name" android:uiOptions="splitActionBarWhenNarrow" > ``` items.xml: ``` <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/phone" android:title="@string/phone" android:icon="@drawable/phone" android:showAsAction="ifRoom|withText" /> <item android:id="@+id/computer" android:title="@string/computer" android:icon="@drawable/computer" android:showAsAction="ifRoom|withText" /> <item android:id="@+id/gamepad" android:title="@string/gamepad" android:icon="@drawable/gamepad" android:showAsAction="ifRoom|withText" /> <item android:id="@+id/camera" android:title="@string/camera" android:icon="@drawable/camera" android:showAsAction="ifRoom|withText" /> <item android:id="@+id/video" android:title="@string/video" android:icon="@drawable/video" android:showAsAction="ifRoom|withText" /> <item android:id="@+id/email" android:title="@string/email" android:icon="@drawable/email" android:showAsAction="ifRoom|withText" /> </menu> ``` I am using this tutorial, and trying to make Figure 6 : Action items and Overflow menu in Split Action Bar Please help me to show Overflow Menu Items (ICON) to ActionBar Now whenever i do click on Menu Button in emulator, then i am getting rest Menu Items....