I have a customized action bar, i want to add navigation drawer icon on Main Activity by clicking it drawer will open/close and on other activities i want a back arrow, clicking it i go back on parent activity. i have done this for drawer icon and it works,
toolbar.setNavigationIcon(R.drawable.ic_menu_black_24dp);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
and for back arrow i have tried this
setDisplayHomeAsUpEnabled(true);
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
this.finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
but only one thing works at a time, how both can work?