2

In Android, when you onLongClick an overflow menu item icon, a tooltip of its title will appear.

I've tried setting the menu title to blank, but a blank tooltip will pop up.

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

    <item android:id="@+id/action_icon"
        android:title="Icon Title"
        android:icon="@drawable/ic_myicon"
        app:showAsAction="always"/>
</menu>

Notes:

• I'm using app namespace because Android Studio is telling me to use it due to having Theme.AppCompat.Light.NoActionBar as my theme. I've tried android namespace. Doesn't work either.

• My menu is created in a Fragment with hasOptionsMenu(true).

• My ActionBar is a Toolbar.

How can I remove this tooltip if it's possible? Thanks!

4
  • 2
    remove title attribute from item for that
    – JAAD
    Commented Feb 6, 2016 at 6:13
  • I've tried it will just give you a blank tooltip as well.
    – mco
    Commented Feb 6, 2016 at 6:13
  • the only way to do this is up is with android:showAsAction="withText"
    – JAAD
    Commented Feb 6, 2016 at 6:30
  • and use title as blank
    – JAAD
    Commented Feb 6, 2016 at 6:31

2 Answers 2

0

Yes it is possible. In the java class remove the public boolean onCreateOptionsMenu(Menu menu) and the job will be done. If no remove this also from the java class public boolean onOptionsItemSelected(MenuItem item)

2
  • This just removes my entire menu completely. Technically that does remove the tooltip lol.
    – mco
    Commented Feb 6, 2016 at 7:14
  • 1
    Remove the public boolean onOptionsItemSelected(MenuItem item) only. Commented Feb 6, 2016 at 8:27
0

the only way to do this is up is with android:showAsAction="withText" and set Title as =""

For onLongClickListener:

final MenuItem menuItem = menu.findItem(R.id.action_search);
            searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
            searchView.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    return false;
                }
            });
9
  • I'm sorry, but this does not work. android:showAsAction="withText" will force my menu item to be only shown as a text item. Together with android:title="" will result in a blank text menu item. I've tried android:showAsAction="always|withText", but this does not work either.
    – mco
    Commented Feb 6, 2016 at 7:02
  • u can override menuitem onlongclick and then do nothing in it to not show tooltip
    – JAAD
    Commented Feb 6, 2016 at 7:06
  • MenuItem does not have a OnLongClickListener. Calling MenuItem.getActionView() is always null too...
    – mco
    Commented Feb 6, 2016 at 7:11
  • they have an onLongClick listener
    – JAAD
    Commented Feb 6, 2016 at 7:14
  • android:showAsAction="withText" is working for me i dont know why it isnt working for you
    – JAAD
    Commented Feb 6, 2016 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.