开发者

What determines if the legacy menu button shows in Honeycomb system bar?

开发者 https://www.devze.com 2023-04-12 16:09 出处:网络
I have an application t开发者_如何学JAVAhat has numerous activities. I set this in the manifest:

I have an application t开发者_如何学JAVAhat has numerous activities. I set this in the manifest:

<uses-sdk android:minSdkVersion="4"  targetSdkVersion="11"/>

I also set up a v11 style so that the activities will all use the Holo Theme on v11+.

The issue is that all of my activities are showing the legacy menu button on the system bar. My activities that have menus (ones in which I use onCreateOptionsMenu) show both the legacy menu button and the action bar overflow menu button at the same time. Pressing the legacy button expands the menu at the upper right corner of the screen.

On my activities that don't use onCreateOptionsMenu, there is still a legacy button that doesn't do anything.

I haven't been able to figure out what's going on. Hackborn has written that targetSdkVersion is the only thing that controls whether the legacy button is shown: link

Edit: Clarified description of problem.


I see you're doing same mistake as I did.

Your targetSdkVesrion name misses android: prefix, so it's actually ignored. It should be:

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11"/>

Just now your app will target v11, and you won't get legacy menu button ever.

Also see related discussions:

  1. Honeycomb themes *.NoActionBar or *.NoTitleBar - where is Menu button?
  2. Android and Honeycomb - how to have a menu icon with SDK 13 without having an "action bar"


You will need to add android:showAsAction="ifRoom|withText" to your menu items in XML. This will throw an error unless you build against Android 3.0. When you switch to this version for build make sure you don't use any 3.0 only method calls because it will crash on older versions without compile time errors.

0

精彩评论

暂无评论...
验证码 换一张
取 消