A
A
Anton Akimov2016-04-20 15:11:12
Android
Anton Akimov, 2016-04-20 15:11:12

Android Studio: How to force display of menu icon (three dots) in ActionBar?

3ce0670753a24907a7eedc0277b662e6.png
As far as I understand, if the device has a "Menu" button, then the menu should be displayed by clicking on it. If there is no such button on the device, then an icon in the form of three dots appears in the ActionBar, and the menu is called when you click on this icon. At least that's how it works in my case.
What I want is that in my application (as in many others) the menu icon is displayed regardless of the presence of a button on the device.
I tried to abandon ActionBar in favor of ToolBar, but the studio starts to swear about compatibility, so I ask you not to offer work with it in advance. Changed app:showAsAction to android:showAsAction and other minor manipulations - did not help. Please help.
Menu creation code:

public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.chat, menu);
        return super.onCreateOptionsMenu(menu);
    }

Layout:
<?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"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".ChatActivity" >

    <item android:id="@+id/clear_history"
        android:title="@string/clear_history"
        android:orderInCategory="0"
        app:showAsAction="never" />
</menu>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Dorofeev, 2016-04-20
@TechCloud

I didn’t quite understand the question, but okay:
Let’s start with the “layout ”:
Replace it with:
If I misunderstood you or the solution did not help, please write about it.

A
Alexey Shumkin, 2016-04-21
@ashumkin

targetSdkVersion in AndroidManifest.xml what is it?
we had this, on some devices it was always visible, even in floating form (on HTC)
I read somewhere (I don’t remember where) that the targetSdkVersion must be at least 14 for it to disappear ...
Perhaps you it is necessary on the contrary, or maybe not at all))
ZY . maybe here android-developers.blogspot.ru/2012/01/say-goodbye...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question