0

I am developing an app that doesnt show up menu items in the top right corner. In google nexus it shows up but not in micromax canvas HD.

below is my menu xml.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/mnuRecentLookUp" android:title="@string/mnuRecentLookUp" android:icon="@drawable/clock" />
<item android:id="@+id/mnuBookmarks" android:title="@string/mnuBookmarks" android:icon="@drawable/bookmarks" />
<!--  <item android:id="@+id/mnuFontSize" android:title="@string/mnuFontSize" android:icon="@drawable/fontsize"/>-->
<item android:id="@+id/mnuHelp" android:title="@string/mnuHelp" android:icon="@drawable/help" />
<item android:id="@+id/mnuClose" android:title="@string/mnuClose" android:icon="@drawable/ic_menu_close" />
</menu>

@Override
public boolean onCreateOptionsMenu( final Menu menu )
{
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.nav_home, menu);

    // Calling super after populating the menu is necessary here to ensure that the
    // action bar helpers have a chance to handle this event.
    return super.onCreateOptionsMenu(menu);
}

I tried overflow to show the 3 dot icon on top right corner.It works fine in 4.0 or more versions not in 2.2-2.3. in android 2.3, it gives noSuchFieldException {shasPermanentmenukey}.

Please help me to solve the issue. I want the things to work on all android versions i.i. 2.2 and above.

Thanks in advance....

Anjali
  • 1,623
  • 5
  • 30
  • 50
  • Canvas HD has a Hard Menu Key where as Nexus doesn't not. This is device specific. And thing that you want to hear won't be said, so here it is: IT CAN'T BE DONE. It was introduced for 4.0 and above. **Alternative:** Use [Actionbar Sherlock](http://stackoverflow.com/questions/13179620/force-overflow-menu-in-actionbarsherlock/13341458#13341458). – Tushar Gogna Feb 24 '15 at 05:11

1 Answers1

0

I had the same problem, overflow could not be visible for API < 11.

I tried this,

Add a menu item with icon i.e. image of three dots, and put another menu items inside that item tag. And set app:showAsAction="always" to that item with three dot image

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app=""http://schemas.android.com/apk/res-auto"">
<item android:id="@+id/menu_three_dots" 
          android:title="@string/menu" 
          android:icon="@drawable/three_dots"
          app:showAsAction="always">
    <item android:id="@+id/mnuRecentLookUp" 
          android:title="@string/mnuRecentLookUp" 
          android:icon="@drawable/clock" />

    <item android:id="@+id/mnuBookmarks"
         android:title="@string/mnuBookmarks"
         android:icon="@drawable/bookmarks" />

    <item android:id="@+id/mnuHelp" 
         android:title="@string/mnuHelp" 
         android:icon="@drawable/help" />

    <item android:id="@+id/mnuClose"
         android:title="@string/mnuClose" 
         android:icon="@drawable/ic_menu_close" />
</item>
</menu>

Now the menu will be visible at top right corner, just click that three dots and it will show the overflow.

Apurva
  • 7,871
  • 7
  • 40
  • 59
  • i tried the above code...but it gives No resource identifier found for attribute 'showAsAction' in package. – Anjali Feb 16 '15 at 12:24
  • @Anjali mistakenly I have put `" "` (double quote) twice in `xmlns:app=""http://schemas.android.com/apk/res-auto""`. Remove one. And you will have to set an image for three dots yourself – Apurva Feb 16 '15 at 12:31