Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I hide the menu button for one activity

Tags:

android

hide

menu

There is an activity which has no menu item. So I want to hide the menu button. Is there any way to achieve that? Thanks

like image 933
tangjie Avatar asked Aug 12 '11 03:08

tangjie


People also ask

How do we hide the menu on the toolbar in one fragment?

How do we hide the menu on toolbar in one fragment? When you click the show button to open a fragment, you can see the fragment menu items ordered before activity menu items. This is because of the menu item's android:orderInCategory attribute value. When you click the hide button to hide the fragment.


1 Answers

I figured out how this can be done. In your AndroidManifest.xml, you need to specify something like the following:

<uses-sdk android:minSdkVersion="8"
          android:targetSdkVersion="14" />

Basically, minSdkVersion is the minimum Android SDK version that you application supports (in my case, 2.2) and targetSdkVersion is the version you're "targetting" (i.e. your "preferred" version - in my case, that's 4.0)

By default, targetSdkVersion is the same as minSdkVersion, and if you leave that pre-Honeycomb, you're basically telling Android that your app is "legacy" and it'll always show the menu button.

If you make targetSdkVersion post-Honeycomb, then the menu button will only be shown if you actually have menu items defined.

like image 166
Dean Harding Avatar answered Sep 30 '22 20:09

Dean Harding