Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
629 views
in Technique[技术] by (71.8m points)

android - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...