0

I'm working on an app for android which has a menu. It works perfectly fine on my ancient phone which has a physical menu button(running 2.2), but on a Kindle Fire the overflow menu button doesn't appear. I'm sorry if this seems like a repeat question but I've tried a lot of the methods listed in other people's answers and haven't had any change.

My menu xml looks like this:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">


<item
    android:id="@+id/action_main"
    android:orderInCategory="100"
    android:title="@string/action_MainMenu"
    app:showAsAction="never"/>

[and so on]

            @Override
        public boolean onCreateOptionsMenu(Menu menu) {

                    getMenuInflater().inflate(R.menu.main, menu);

                    //[here I have a few if statements to rename items or remove unnecessary ones]
                    return true;
                }

1 Answers1

0

Overflow menu at times doesnt appear for devices with physical Menu key. A very nice hack has been provided by Commonsware for this.

 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) {
 // presumably, not relevant
}

Source.

Community
  • 1
  • 1
Atul O Holic
  • 6,692
  • 4
  • 39
  • 74
  • Thank you for the response. I have tried this and it made no difference. Also this device has no physical menu key. – user3637539 May 14 '14 at 19:25