Fragmentactivity with Actionbardrawertoggle

Asked

Viewed 46 times

1

I would like to create a Drawer with a Actionbardrawertoggle.
I’m following this tutorial!
My only change is that I’m extending a FragmentActivity and not a Activity as the example.
When I run occurs one NullPointer in the following line:

getActionBar().setDisplayHomeAsUpEnabled(true);

For the getActionBar() is void!.
Would anyone know how to put one ActionBarDrawerToggle in a FragmentActivity?

1 answer

2


I think he’s using the v7 appcompat library.
To gain access to Actionbar your Activity shall inherit from Actionbaractivity or better than Appcompactactivity since Actionbaractivity was considered obsolete.

You can then get a reference to Actionbar using:

ActionBar actionBar = getSupportActionBar(); 

Appcompactactivity is a Fragmentactivity with support to Actionbar.

  • I tested it here and it worked correctly! Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.