Use following code to add back button functionality in android
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.arwbck);
toolbar.setOverflowIcon(getResources().getDrawable(R.drawable.menuicn));
toolbar.setTitleTextColor(Color.RED);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
toolbar.setNavigationIcon(R.drawable.arwbck);
toolbar.setOverflowIcon(getResources().getDrawable(R.drawable.menuicn));
toolbar.setTitleTextColor(Color.RED);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
@Override
public boolean onSupportNavigateUp(){
finish();
return true;
}
No comments:
Post a Comment