getSupportActionBar() returning null when using theme no matter what I try

1,434 views
Skip to first unread message

chris harper

unread,
Mar 4, 2013, 2:09:28 PM3/4/13
to actionba...@googlegroups.com

Hello 

I have gone though the other posts related to getSupportActionBar() returning null and tried various solutions but I still can't get getSupportActionBar() to return an object when using a theme. 

I am extending from SherlockFragmentActivity and in AndroidManifest.xml every time I try to use a theme for my activity, getSupportActionBar() returns null. 

If I DON'T use a theme for my activity in AndroidManifest.xml then getSupportActionBar() DOES return an object.

I tired setting android:theme="@style/Theme.Sherlock" at the application and activity level within the AndroidManifest.xml but if I set it in either then  getSupportActionBar() returns null. 

I also tied using my own theme by doing:

    <style name="MyTheme" parent="@android:Theme.Holo.Light">

        <item name="android:windowActionBar">false</item>

        <item name="windowNoTitle">false</item>

       </style>

 and setting windowNoTitle to true and to false but either way I still get null back from getSupportActionBar().

 In my project I am using android SDK 4.0 with java version 1.60.

I am testing on an HTC 4G lite running 4.1.1.

I am at a loss what I am doing wrong. 

Thank you in advance.




chris harper

unread,
Mar 4, 2013, 2:18:04 PM3/4/13
to actionba...@googlegroups.com
One more thing I forgot to mention I am calling getSupportActionBar() after onCreate() and setContentView(). 
I know that is important. So it's not that.

    protected void onCreate(Bundle bundle1) {
        ActionBar obj = null;
        super.onCreate(bundle1);
        setContentView(R.layout.main_pager);
        obj = getSupportActionBar();
Reply all
Reply to author
Forward
0 new messages