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


此问题的stackoverflow版本

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


我的sdk version设置如下:

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

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


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


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.

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).

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

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

    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:

    <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.


你可能感兴趣的:(android)