Android menu and action bar conversion

前端 未结 4 798
感动是毒
感动是毒 2021-02-09 20:41

There is a new concept in Android:

http://android-developers.blogspot.com/2012/01/say-goodbye-to-menu-button.html

But it isn\'t clear fro me. I have an applicati

4条回答
  •  心在旅途
    2021-02-09 20:58

    Per the blog post that you shared:

    Summary

    Android no longer requires a dedicated Menu button, some devices don’t have one, and you should migrate away from using it.

    Set targetSdkVersion to 14, then test your app on Android 4.0.

    Add showAsAction="ifRoom" to menu items you’d like to surface in the action bar.

    If the ActionBar doesn’t work for your app, you can remove it with Theme.Holo.NoActionBar or Theme.DeviceDefault.NoActionBar.

    So, all you really have to do is this:

    First, set your SDK min and target version in the AndroidManifest.xml file like this:

    Second, add showAsAction="ifRoom" to the menu items in your menu.xml file.

    Now run your app in Honeycomb or Ice Cream Sandwich and you should see your menu in the action bar. Your app should still work for the pre Android 3.0 releases.

提交回复
热议问题