Add
actionBar.setHomeButtonEnabled(true);
and then add the following
@Override
public boolean onOptionsItemSelected(MenuItem menuItem)
{
switch (menuItem.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(menuItem);
}
}
As suggested by naXa I've added a check on the itemId
, to have it work correctly in case there are multiple buttons on the action bar.