Android: getSupportActionBar() always returns null in ActionBarSherlock library

前端 未结 14 625
盖世英雄少女心
盖世英雄少女心 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:26

    You should add the Sherlock theme to your application

    <application android:icon="@drawable/icon" android:label="@string/app_name"
            android:debuggable="false" android:theme="@style/Theme.Sherlock">
    
    0 讨论(0)
  • 2020-11-29 06:26

    Another reason you might get null from getSupportActionBar() is trying to call it before setContentView(R.layout.main) or in your example adding a fragment.

    I refactored oncreate and mistakenly put getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); after super.onCreate(savedInstanceState);

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