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
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
You can do using the onPrepareOptionsMenu, where you set the menu item that you want to show to user,[http://developer.android.com/reference/android/app/Activity.html#onPrepareOptionsMenu%28android.view.Menu%29][1]
[1]: http://developer.android.com/reference/android/app/Activity.html#onPrepareOptionsMenu%28android.view.Menu%29. Do not inflate using the xml just do it manually.
Thank you.
Try this to include in your code so that the menu items are not automatically visible when you start the activity.
By writing like this the menu items are visible only when you click on the menu button of the android smartphone
On the vast majority of Android devices, the "menu button" is a physical thing, and cannot be hidden, any more than I can hide a mountain or a molehill.
On Honeycomb, if you do not define an options menu, you should not get the "overflow" button in the upper right corner, in the action bar.
If you are trying this on some non-compliant Android device that does its own soft menu button, you are out of luck.
I figured out how this can be done. In your AndroidManifest.xml, you need to specify something like the following:
Basically,
minSdkVersion
is the minimum Android SDK version that you application supports (in my case, 2.2) andtargetSdkVersion
is the version you're "targetting" (i.e. your "preferred" version - in my case, that's 4.0)By default,
targetSdkVersion
is the same asminSdkVersion
, 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.