Use following code to add back button functionality in android
![Image2](https://shdhumale.files.wordpress.com/2016/07/image2.png)
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