Sunday, July 03, 2016

Add back functionality with button on android and icon

Use following code to add back button functionality in android
Image2
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);

@Override
public boolean onSupportNavigateUp(){
finish();
return true;
}


No comments: