【随手记】ActionBar Action Items not showing 菜单项没法显示


此问题的stackoverflow版本html

http://stackoverflow.com/questions/17913084/actionbar-action-items-not-showing android


个人sdk version设置以下:app

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

由于target版本的设置问题,这里必须使用兼容的写法,而不能使用标准方法ide


官方说明 点这里: Support Android 2.1 and Aboveui


Adding the action bar when running on versions older than Android 3.0 (down to Android 2.1) requires that you include the Android Support Library in your application.spa

To get started, read the Support Library Setup document and set up the v7 appcompat library (once you've downloaded the library package, follow the instructions for Adding libraries with resources).code

Once you have the Support Library integrated with your app project:orm

  1. Update your activity so that it extends ActionBarActivity. For example:xml

    public class MainActivity extends ActionBarActivity { ... }
  2. In your manifest file, update either the <application> element or individual <activity> elements to use one of the Theme.AppCompat themes. For example:htm

    <activity android:theme="@style/Theme.AppCompat.Light" ... >

    Note: If you've created a custom theme, be sure it uses one of the Theme.AppCompat themes as its parent. For details, see Styling the Action Bar.

相关文章
相关标签/搜索