I have a custom android action bar with a custom layout view and style. I need to show the 'Home As Up' Button for my navigation drawer. The problem is that the button is not showing up in my custom layout style. I need the android default home as up icon so that I may have a default navigation drawer icon. (The icon which has the animation of the navigation drawer opening and closing).
Now I tried doing
getActionBar().setDisplayHomeUpAsEnabled(true);
getActionBar().setHomeButtonEnabled(true)
But the home button does not show up. Can anyone tell my how to implement the default home button on the custom actionbar?
For me this works to display the up navigation. I'm still figuring out how to actually implement the up navigation.
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
It appears you can just use the convenience function to handle up like this:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent intent;
intent = NavUtils.getParentActivityIntent(this);
NavUtils.navigateUpTo(this, intent);
return true;
}
return super.onOptionsItemSelected(item);
}
To handle buttons in the custom part you can add onClick in the layouts and implement the specified functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With