Android: getSupportActionBar() always returns null in ActionBarSherlock library

前端 未结 14 624
盖世英雄少女心
盖世英雄少女心 2020-11-29 05:29

I\'m trying to use the ActionBarSherlock library to provide backwards compatible ActionBar support with tabs in my Android app, so I downloaded the latest build, built the d

相关标签:
14条回答
  • 2020-11-29 06:04

    I just changed in Manifest

    android:theme="@style/AppTheme.NoActionBar"
    

    to:

      android:theme="@style/AppTheme"
    

    and the error gone

    0 讨论(0)
  • 2020-11-29 06:05

    I had this problem after (sillily) forgetting to call the super.onCreate()

    0 讨论(0)
  • 2020-11-29 06:05

    I ran into this after adding a library to my project. The remedy was to look in the library and remove any styles name "AppTheme" if you are using this same theme name in your manifest. There wasn't a conflict on my Galaxy S4, Jelly Bean, while there was a conflict on my Galaxy Tab.

    0 讨论(0)
  • 2020-11-29 06:07

    Another reason this will happen on Honeycomb+ devices is because the windowNoTitle attribute is set in your style. Get rid of that as ActionBarSherlock will automatically remove it in pre-Honeycomb devices for you.

    0 讨论(0)
  • 2020-11-29 06:12

    you are declared Theme.Sherlock or Theme.Sherlock.Light as your activity or application theme in the manifest Or using a custom theme that inherits from one of these two

    Example:-

    <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.Sherlock.Light" >
    

    also u can use dark theme:-

    android:theme="@style/Theme.Sherlock"
    
    0 讨论(0)
  • 2020-11-29 06:12

    I added android:theme="@android:style/Theme.Dialog" to my activity in the Android Manifest file in an attempt to make it a dialogue activity. This too will remove the action bar hence a null pointer. Remove it or don't call getSupportActioBar

    0 讨论(0)
提交回复
热议问题