How to disable/hide three-dot indicator(Option men

2019-01-16 14:01发布

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.

19条回答
ら.Afraid
2楼-- · 2019-01-16 14:27

This is how I find a solution of mine. It maybe helpful.

@Override
public boolean onKeyDown(int keycode, KeyEvent event ) {
    //KEYCODE_MENU
 if(keycode == KeyEvent.KEYCODE_MENU){
 /* AlertDialog.Builder dialogBuilder 
  = new AlertDialog.Builder(this)
  .setMessage("Test")
  .setTitle("Menu dialog");
  dialogBuilder.create().show();*/
  return true;

//  finish();
 }
 return super.onKeyDown(keycode,event);  
}
查看更多
叼着烟拽天下
3楼-- · 2019-01-16 14:28
for hiding 3 dots in actionbar/ toolbar

 public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_dash_board_drawer, menu);
        return false;  //for visible 3 dots change to true, hiding false
    }
查看更多
一夜七次
4楼-- · 2019-01-16 14:28

I just used

 @Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

Where R.menu.main is only an empty menu xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" ></menu>
查看更多
一纸荒年 Trace。
5楼-- · 2019-01-16 14:31

You can actually change the Android targetVersion thus forcing the 3-dot menu to either hide or show. You need to override onCreate of your Activity like this :

@Override
public void onCreate(Bundle savedInstanceState) {
    getApplicationInfo().targetSdkVersion = 10; // To enable the 3-dot menu call this code before super.OnCreate
    super.onCreate(savedInstanceState); 
}

@Override
public void onCreate(Bundle savedInstanceState) {
    getApplicationInfo().targetSdkVersion = 14; // To disable the 3-dot menu call this code before super.OnCreate
    super.onCreate(savedInstanceState); 
}

Tested on Android 4.x.x and Android 3.0

查看更多
萌系小妹纸
6楼-- · 2019-01-16 14:33

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.

查看更多
淡お忘
7楼-- · 2019-01-16 14:33
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
       return false;
 }
查看更多
登录 后发表回答