【隨手記】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.

相關文章
相關標籤/搜索