How to add Action Bar from support library into PreferenceActivity?

后端 未结 8 698
不思量自难忘°
不思量自难忘° 2020-11-27 09:15

Action Bar compatibility has been added into support library, revision 18. It now has ActionBarActivity class for creating activities with Action Bar on older versions of An

8条回答
  •  天涯浪人
    2020-11-27 09:48

    I was able to get android.app.Actionbar by using getActionBar(). It returned a null value at first... then I went to the manifest and changed the theme to:

    android:theme="@style/Theme.AppCompat"

    Then I was able to have the actionbar again. I'm assuming this will only work for certain build levels. So you might want to do a check for the build number or check if the value returned is null.

    It'll be fine for me because the app I'm working on is for ICS/4.0+.

提交回复
热议问题