Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show Overflow Menu Items to Action Bar in Android

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: enter image description here

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....

like image 331
Babu Avatar asked Mar 19 '13 06:03

Babu


People also ask

How do you add action items to the action bar in Android?

All action buttons and other items available in the action overflow are defined in an XML menu resource. To add actions to the action bar, create a new XML file in your project's res/menu/ directory. The app:showAsAction attribute specifies whether the action should be shown as a button on the app bar.

Where is the action overflow menu icon?

The right-hand side of the action bar shows the actions. The action buttons (3) show the most important actions of your app. Actions that do not fit in the action bar are moved to the action overflow, and an overflow icon appears on the right.

Where is the overflow menu on Android?

The Android overflow menu is accessed from the far right of the actions toolbar at the top of the display of the running app. This menu provides a location for applications to provide additional options to the user.


1 Answers

Just to say that If your device has a menu-button, the overflow-icon won't show, on the newer phones the overflow button will show. I would not reccomend ASMUIRTI's answer since it is an awful hack that breaks consistency with the rest of the apps on the platform.

you must use

android:showAsAction="never" 

and let the android device decide if the overflow menu is needed for that device.

like image 153
Akshat Agarwal Avatar answered Sep 21 '22 19:09

Akshat Agarwal