Android Overflow Menu Button is not visible on some phones - android

The app runs fine. On devices with hard options menu button the menu shows up, so i know it works. On some devices it shows the overflow button at the top-right.
I my test case the device is Asus Zenphone 5 there is no hard button, i dont get a overflow button either. But when i run the showOptionsMenu() command from a button click it displays the options menu and all related events work no issues.
Menu - Xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#+id/select" android:title="Select" android:showAsAction="never"></item>
<item android:id="#+id/add_kid" android:title="Add" android:showAsAction="never"></item>
</menu>
onCreate & onPrepare
#Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.menu1, menu);
return super.onCreateOptionsMenu(menu);
}
#Override
public boolean onPrepareOptionsMenu(Menu menu)
{
if(!getCheckInStatus())
{
menu.setGroupVisible(R.id.group1,false);
}
else
{
menu.setGroupVisible(R.id.group1,true);
}
return super.onPrepareOptionsMenu(menu);
}
Manifest values for the Activity
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
.....
<activity
android:name="com.my.package.MyActivity"
android:configChanges="orientation|keyboard"
android:label="#string/app_name"
android:launchMode="singleInstance"
>
</activity>
I would really appreciate any help on this matter.

I used to have same problem in few of my projects. I followed the steps given below which worked for me
1. extends your activity to ActionBarActivity
call the following code in onCreate method
private void makeActionOverflowMenuShown()
{
//devices with hardware menu button (e.g. Samsung Note) don't show action overflow menu
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) {
}
}

set android:showAsAction="ifRoom" in menu.xml, the button would show.

Try like this. This works for me..
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:icon="#drawable/ic_action_overflow"
android:id="#+id/moreItmes"
android:showAsAction="never"
android:title="#string/more">
<menu>
<item
android:id="#+id/select"
android:showAsAction="never"
android:title="#string/Select"/>
<item
android:id="#+id/add_kid"
android:showAsAction="never"
android:title="#string/Add"/>
</menu>
</item>
</menu>

As i commented in vinay's answer , the reason was that i was debugging an old program written by some one else. It seems all were Activities , but i had changed the target and compile-with to 22. Once i changed the Activity to ActionBarActivity the overflow appeared on the devices with soft menu button. While those with hard options menu button did not display it.

Menu - Xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#+id/select" android:title="Select" android:showAsAction="never"></item>
<item android:id="#+id/add_kid" android:title="Add" android:showAsAction="never"></item>
</menu>
in your menu.xml you just use showAsAction as never which represent Never place this item in the Action Bar. please refer the link for more info

Related

Adding Action Bar to an android app

I'm using this guide http://developer.android.com/guide/topics/ui/actionbar.html to create and add items to the action bar in my app. However the items aren't showing up. This is the menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#+id/action_alert"
android:icon="#drawable/ic_dialog_alert"
android:title="#string/action_alert"
android:showAsAction="ifRoom" />
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="never" />
I already added the theme in the manifest
<application
android:allowBackup="true"
android:debuggable="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo" >
And finally this is the onCreateOptionsMenu in the Activity
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_main, menu);
return super.onCreateOptionsMenu(menu);
}
I know the Action Bar is working fine because I can hide it with this without problems
ActionBar actionBar = getActionBar();
actionBar.hide();
What am I missing?
When working with devices a hardware settings button your overflow button is moved to the settings button, there are two alternatives to get around this:
xml:
Instantiate your own overflow:
<item android:title=""
android:id="#+id/more"
android:showAsAction="always"
android:icon="#drawable/overflow">
<menu>
<item android:id="#+id/action_alert"
android:icon="#drawable/ic_dialog_alert"
android:title="#string/action_alert"
android:showAsAction="never" />
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="never" />
</menu>
</item>
.java:
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();
}
If your concern is that there are no icons showing up, try changind android:showAsAction="..." to android:showAsAction="always". This will explicitly show the icons. This is not a good solution if you're supporting multiple screen resolutions though.
XML Namespace
Try a custom namespace like below in your menu.xml file. You can replace custom by whatever you like.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto" >
And then use that namespace in your items (same xml file) instead of the android namespace
<item android:id="#+id/action_alert"
android:icon="#drawable/ic_dialog_alert"
android:title="#string/action_alert"
custom:showAsAction="ifRoom" />
Complete (working) Example
A more complete example can be found at this menu-drawer-compat-example on github. Content of the menu xml file there is:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:hcpl="http://schemas.android.com/apk/res-auto" >
<!-- used custom ns hcpl to force display of action buttons -->
<item
android:id="#+id/action_websearch"
android:icon="#drawable/action_search"
android:showAsAction="ifRoom|withText"
android:title="#string/action_websearch"
hcpl:showAsAction="ifRoom"/>
</menu>
This is an example project for the Android compat Actionbar, keep that in mind if you compare your code.

Action Bar not showing in 4.2.2

SOLUTION: It was a problem with the image search icon. Android did not find the image for the search action , I had not added them in all the
res-folders , it started to show after that...
I am trying to add the action bar to a app and I am following the basic app tutorial shown in the Google Developer Website
I have written the following code.
MainActivity
public class MainActivity extends ActionBarActivity {
public void openSearch(){
System.out.println("TEST SEARCH");
}
public void openSettings(){
System.out.println("TEST SETTINGS");
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions, menu);
return super.onCreateOptionsMenu(menu);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.action_search:
openSearch();
return true;
case R.id.action_settings:
openSettings();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
res/menu/main_activity_actions.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Search, should appear as action button -->
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="never" />
</menu>
AndroidManifest.xml
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.sample.actionbarsample.MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
But instead of a Action bar like this
I get A options menu. Which shows up when I press the menu button while running the app.
What is that I am missing out from the tutorial, Or is there something wrong in the code?
EDIT
After doing what beworker asked me I got this result, still missing the search box.
Nothing wrong either with you code or with the tutorial. It's all about configuration of your emulator. You need to configure your emulator in the way, that it has software buttons. Switch to "Device Definition" tab and edit device that is uses "Software" buttons as in the picture below.
Alternatively you can simply uncheck "Keyboard / Hardware keyboard present" property in ADV configuration (see picture below) and restart your emulator.
Android 4.0 emulates old-style menu, if a hardware menu button is present. That is why all menu actions will go in there. If you disable hardware menu in emulator, then actions will go to action bar, as expected.
Please note, that on phones with hardware menu buttons like Samsung G2, G3 etc. menu popup will still appear and you cannot change this in your code. Android will decide what is better for user experience on each and every device.
Update
Another note. If you use compatibility library, make sure you use xmlns:yourapp="http://schemas.android.com/apk/res-auto" and yourapp:showAsAction="always" as described below.
However, if your app is using the Support Library for compatibility on
versions as low as Android 2.1, the showAsAction attribute is not
available from the android: namespace. Instead this attribute is
provided by the Support Library and you must define your own XML
namespace and use that namespace as the attribute prefix.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<!-- Search, should appear as action button -->
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
yourapp:showAsAction="always" />
...
</menu>
What is that I am missing out from the tutorial, Or is there something wrong in the code?
Yes, there is a difference.
Try to remove the sample word from your project.
Actually your project name is occupying all the space and in search menu item you have asked the system to provide the space if there is any room/space available which is not due to the long project name(may be activity or whatever) in your case.
So either change your project name to something small or use "always" like this:
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:showAsAction="always" />

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:
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....
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.
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();
}
}
This could be another work around, which really helped me. Keep one drawable with three dots and give it as a menu item.
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/saveDetails"
android:showAsAction="always"
android:title="#string/save"/>
<item
android:id="#+id/menu_overflow"
android:icon="#drawable/dts"
android:orderInCategory="11111"
android:showAsAction="always">
<menu>
<item
android:id="#+id/contacts"
android:showAsAction="never"
android:title="Contacts"/>
<item
android:id="#+id/service_Tasks"
android:showAsAction="never"
android:title="Service Tasks"/>
<item
android:id="#+id/charge_summary"
android:showAsAction="never"
android:title="Charge Summary"/>
<item
android:id="#+id/capture_signature"
android:showAsAction="never"
android:title="Capture Signature"/>
</menu>
</item>
</menu>
If I understand your question correctly and you want to show all your icons on the action bar change this parameters in your menu items
android:showAsAction="ifRoom|withText"
to this
android:showAsAction="always"
If you are using from supporting libraries, in order to show menu items in action bar you must use from the following syntax in your xml:
yourappname:showAsAction="ifRoom|withText"
The phones which have menu hardware button show extra menu items on click of the hardware button. Newer phones, with no hardware menu button automatically add an Overflow menu icon to the Action Bar.
The extra menu items are those which have "showAsAction" property set to never.
Within AndroidManifest.xml between add
android:theme="#android:style/Theme.Holo.Light"
which adds the action bar in your application.
After that, go to menu.xml and add the followings
xmlns:tools="http://schemas.android.com/tools
between
Finally in each item add
android:showAsAction="always"
tools:ignore="AppCompatResource"

MenuItem not being found but is being shown on the screen

I am currently working on an android project and I am having a bit of a strange issue. Its probably something really simple I'm missing but can't see what I've done wrong.
I've added a new menu item to my XML file and then I am trying to reference the new menu item to either show it or hide it. The menu item is being shown on the screen when I run the app so I know I have the XML correct and have the correct file but when I try and do findViewById it returns null.
Below is the code.
MenuItem mnuUpgrade;
mnuUpgrade = (MenuItem)findViewById(R.id.mnu_upgrade);
if (common.checkForProVersion())
{
//mnuUpgrade.setVisible(false);
}
else
{
//mnuUpgrade.setVisible(true);
}
and below is my XML file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#+id/mnu_addLogin"
android:title="New Login"
android:icon="#android:drawable/ic_menu_add"
android:showAsAction="always">
</item>
<item android:id="#+id/mnu_search"
android:title="Search"
android:icon="#android:drawable/ic_menu_search"
android:showAsAction="always">
</item>
<item android:id="#+id/mnu_settings"
android:title="Settings"
android:showAsAction="ifRoom"
android:icon="#android:drawable/ic_menu_manage">
</item>
<item android:id="#+id/mnu_upgrade"
android:title="Upgrade"
android:showAsAction="ifRoom"
android:icon="#android:drawable/ic_menu_upload">
</item>
<item android:id="#+id/mnu_logout"
android:title="Log out"
android:showAsAction="ifRoom"
android:icon="#android:drawable/ic_menu_close_clear_cancel">
</item>
</menu>
Thanks for any help you can provide.
The findViewById can't find a MenuItem. You can use the onPrepareOptionsMenu in your activity. It's called when user tries to open the menu. You can try this:
#Override
public boolean onPrepareOptionsMenu (Menu menu) {
MenuItem item = menu.getItem(3);
// the number is the position of your "upgrade" item in the menu, starting from 0
// then check for the pro version
if(common.checkForProVersion()) {
item.setVisible(false);
} else {
item.setVisible(true);
}
}

Android action bar not showing overflow

I have an action bar in my app with 3 items.
Only 2 can be displayed due to space issues, so I'd expect the first to be displayed and the rest to be displayed in the overflow.
However in practice only the first 2 items are shown and there is no overflow detectable.
Here is the relevant code:
list_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#+id/menu_insert"
android:icon="#android:drawable/ic_menu_add"
android:title="#string/menu_insert"
android:showAsAction="ifRoom|withText"/>
<item android:id="#+id/menu_call"
android:icon="#android:drawable/ic_menu_call"
android:title="#string/menu_call"
android:showAsAction="ifRoom|withText"/>
<item android:id="#+id/menu_agenda"
android:icon="#android:drawable/ic_menu_agenda"
android:title="#string/menu_agenda"
android:showAsAction="ifRoom|withText"/>
</menu>
Activity.java
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater mi = getMenuInflater();
mi.inflate(R.menu.list_menu, menu);
return true;
}
If you want to show the three dots, irrespective of device menu button! then you can call this method in your application class' onCreate method-
private void makeActionOverflowMenuShown() {
//devices with hardware menu button (e.g. Samsung Note) don't show action overflow menu
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) {
Log.d(TAG, e.getLocalizedMessage());
}
}
Output
res/menu/menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Search / will display always -->
<item
android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:showAsAction="always"
android:title="#string/action_search"/>
<!-- Location Found -->
<item
android:id="#+id/action_location_found"
android:icon="#drawable/ic_action_location_found"
android:showAsAction="always"
android:title="#string/action_location_found"/>
<!-- More -->
<item
android:id="#+id/a_More"
android:icon="#drawable/ic_action_overflow"
android:showAsAction="always"
android:title="More">
<menu>
<!-- Refresh -->
<item
android:id="#+id/action_refresh"
android:icon="#drawable/ic_action_refresh"
android:showAsAction="never"
android:title="#string/action_refresh"/>
<!-- Help -->
<item
android:id="#+id/action_help"
android:icon="#drawable/ic_action_help"
android:showAsAction="never"
android:title="#string/action_help"/>
<!-- Check updates -->
<item
android:id="#+id/action_check_updates"
android:icon="#drawable/ic_action_refresh"
android:showAsAction="never"
android:title="#string/action_check_updates"/>
</menu>
</item>
</menu>
MainActivity.java
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu);
}
}
Download the Action Bar Icon Set
I realize this is not an overflow menu, but it is similar.
Okay, this is simple but was hard to figure out.
You first need a menu item you want to use as the overflow inflater. Example
<item
android:id="#+id/a_More"
android:icon="#drawable/more"
android:showAsAction="always"
android:title="More">
</item>
Once you have your item, add a sub-menu containing your items you want in the overflow menu. Example:
<item
android:id="#+id/a_More"
android:icon="#drawable/more"
android:showAsAction="always"
android:title="More">
<menu>
<item
android:id="#+id/aM_Home"
android:icon="#drawable/home"
android:title="Home"/>
</menu>
</item>
On click this will inflate other items within. My application is using ActionBarSherlock 4.0 so before this will work for you, you will need to access the "SplitActionBar". (Will still work on default android Actionbar)
Here's how:
In your AndroidManifest.xml file, you need to add this code under the activity you need the overflow menu in.
android:uiOptions="splitActionBarWhenNarrow"
NOTE: Your item that inflates your overflow menu MUST showAsAction="always"
Vwola! you have an overflow menu! Hope I helped you out. :)
On devices with hardware menu buttons (Galaxy S3, stubborn as Samsung is...) the overflow menu behaves as the 'traditional' menu, by using the hardware menu button.
When you say "overflow" menu, do you mean the three dots that show up in the end to indicate that there are more items.... or do you mean the split actionbar that shows up in the bottom for overflow items?
If you mean the split action bar, you should add this to your activity's manifest file
android:uiOptions="splitActionBarWhenNarrow"
By default, the three dots overflow menu should happen automatically, so it's hard to tell what the problem is from the information you provided above.
To alway show action overflow (three dot) on actionbarcompat:
in menu file, example:
main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="#+id/action_settings"
android:title="#string/action_settings"
app:showAsAction="never"/>
<item
android:id="#+id/action_about"
android:title="#string/action_about"
app:showAsAction="never"/>
</menu>
and in activity file:
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
It's worked fine for me.
Tested on Google Nexus S, Samsung S3.
It appears that on devices with a menu button the overflow menu does not show in the ActionBar. Also we have no way to know if a device has a hardware menu button before API level 14 (4.0+).
This solution adds a overflow button to a android.support.v7.app.ActionBar that opens the standard options menu on pre-Honeycomb (<3.0) only, otherwise leaving it to the system. In any case you can choose between always or ifRoom for all actions.
Get the overflow icon from the Action Bar Icon Pack.
Add a menu (I'omitting some non-relevant parts as titles, ordering etc.)
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/action_overflow"
android:orderInCategory="100"
android:icon="#drawable/ic_action_overflow"
app:showAsAction="always" />
<item
android:id="#+id/action_first"
app:showAsAction="always" />
<item
android:id="#+id/action_second"
app:showAsAction="ifRoom" />
</menu>
Remove our overflow action on 3.0+
#Override
public boolean onPrepareOptionsMenu(Menu menu) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
menu.removeItem(R.id.action_overflow);
}
return super.onPrepareOptionsMenu(menu);
}
Finally call Activity.openOptionsMenu() from the overflow action.
Er... no. You cannot not call openOptionsMenu() from a menu button... but if you are using AndroidAnnotations you're done easily:
#OptionsItem
void action_overflow() {
openOptionsMenuDeferred();
}
#UiThread
void openOptionsMenuDeferred() {
openOptionsMenu();
}
If not you should do something like this, I suppose
#Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == id.action_overflow) {
openOptionsMenuDeferred();
return true;
}
}
private Handler handler = new Handler(Looper.getMainLooper());
public void openOptionsMenuDeferred() {
handler.post(new Runnable() {
#Override
public void run() {
openOptionsMenu();
}
}
);
}
Try changing the theme of the app from
Theme.AppCompat.Light.DarkActionBar to Theme.AppCompat.Light
Put xmlns:your_app_name="http://schemas.android.com/apk/res-auto" inside menu tag
and instead android:showAsAction="always" use your_app_name:showAsAction="always"
for eg
<item
android:id="#+id/action_search"
android:icon="#drawable/icon_search"
android:title="#string/search"
your_app_name:showAsAction="ifRoom"/>

Categories

Resources