I'm trying to use the support v4 ActionBarDrawerToggle
in order to change the action bar indicator to a back arrow instead of the navigation drawer's 3 dots. I'm also using the v4 Fragment
, v4 Drawerlayout
, v7 ActionBar
and v7 ActionBarActivity
.
This is how I have used it:
in onCreate:
DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer,
R.string.navigation_drawer_open, R.string.navigation_drawer_close);
When I try to change the indicators, I got no problems calling setDrawerIndicatorEnabled
on the ActionBarDrawerToggle
but I get the above error when trying to call setHomeAsUpIndicator
. I can only call setHomeAsUpIndicator
on getSupportActionBar()
:
public void turnOnActionBarUpIndicator()
{
mDrawerToggle.setDrawerIndicatorEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(null); //this compiles
mDrawerToggle.setHomeAsUpIndicator(null); //this line does not compile
}
This results in the indicator's look being changed but not it's functionality meaning that I see an arrow as an indicator, but it opens up the drawer instead of going up the backstack.
How can I get both the look AND functionality of the ActionBar
?
Arguably, if you've got a left drawer for navigation that can be opened up with a swipe from the left, you should always have the hamburger in the top left for opening it up. Makes your navigation hierarchy sorta messy, because it doesn't obey common conventions for how the hamburger menu works.
Second, the v4 toggle is deprecated, use v7.