When I click on the UpButton (actionBar's left arrow), it opens my drawer menu instead, and the onOptionsItemSelected method don't receive anything.
How can I prevent my drawer menu from intercepting the Upbutton's click?
AndroidManifest.xml :
<activity
android:name=".ChildActivity"
android:theme="@style/AppTheme.NoActionBar"
android:parentActivityName=".ParentActivity">
ChildActivity - OnCreate :
// Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
this.setSupportActionBar(toolbar);
ActionBar actionBar = this.getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
// Drawer Menu
DrawerLayout drawer = (DrawerLayout) this.findViewById(R.id.main_drawer);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.drawer_open, R.string.drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) this.findViewById(R.id.main_navigation);
navigationView.setNavigationItemSelectedListener(this);
ChildActivity - onOptionsItemSelected :
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
// This code is never executed
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
Ps : The drawer or the upButton, separately, work just fine. I can disable/hide the drawer in the ChildActivity and bring it back after, but I do not think it is the right thing to do.