Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable/hide three-dot indicator(Option menu indicator) on ICS handsets

How to disable/hide three-dot indicator(Option menu indicator) on ICS handsets which does't have menu button. ?

I am running application as <uses-sdk android:minSdkVersion="5"/> in Manifest, code is compiled with 4.0. Three-dot indicator shows on every screen.

Example for preference activities i don't want show Three-dot indicator, since it does't have any menu options.

Adding android:targetSdkVersion="14" in manifest it works. However don't want hide/remove three dots button on all screens . Only in preference activities don't want to show this three dots button.

like image 509
Subba Avatar asked Feb 09 '12 06:02

Subba


4 Answers

Override onPrepareOptionsMenu() in the fragment of the preference with this:

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item= menu.findItem(R.id.menu_settings);
    item.setVisible(false);
    super.onPrepareOptionsMenu(menu);
    return true;
}

if you have more then one item set all the items visibility flag to false

and add the command setHasOptionsMenu(true); to the onCreate command

after you will set all the visibility of the items to false the menu will disappear

on activity, the only difference is the onPrepareOptionsMenu is boolean and you don't need to add the setHasOptionsMenu(true); command on the creation

like image 145
Asaf Manassen Avatar answered Nov 16 '22 01:11

Asaf Manassen


I just deleted the method :

@Override
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
    getSupportMenuInflater().inflate(R.menu.main, menu);
    return true;
}

then that three-dot-menu goes away (:


Hope it helps.

like image 27
alicanbatur Avatar answered Nov 16 '22 01:11

alicanbatur


 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
       return false;
 }
like image 17
dnocode Avatar answered Nov 16 '22 01:11

dnocode


There is no way to show/hide "three-dot" menu indicator for a single activity. You can hide this menu indicator only for entire app by specifying android:targetSdkVersion="14" (or above) in your manifest file.

However, this menu indicator is not showing on preferences activity if it extends from native android.preference.PreferenceActivity class. I have this scenario implemented in a few of my apps, and it works perfectly.

I assume you are using some custom preferences implementations which does not extends from PreferenceActivity. Android Dev Team suggests to always use PreferenceActivity for any preferences in your applications.

like image 9
HitOdessit Avatar answered Nov 15 '22 23:11

HitOdessit