Setting the following makes the home icon show a press state:
actionBar.setHomeButtonEnabled(true);
But, after setting OnClickListener the home icon stops showing the press state:
ImageView iconImage = (ImageView) activity.findViewById(android.R.id.home);
iconImage.setOnClickListener(new android.view.View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
Any idea on how to prevent disabling the press state?
To handle the click on the home
icon , you do not need to set onClickListener
, you need to do the following..
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == android.R.id.home) { //app icon in action bar clicked; go back
//do something
return true;
}
return super.onOptionsItemSelected(item);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With