Back Arrow in Action bar Sherlock is not displayin

2019-03-19 16:17发布

In my project I have used action bar sherlock library. I want to make back button in action bar I used following code

getSupportActionBar().setHomeButtonEnabled(true);

And

@Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {

        case android.R.id.home:
             finish();
             break;

        default:
            return super.onOptionsItemSelected(item);
        }
        return false;
    }

Every thing is working fine, but back Arrow (to the left of icon) is not displaying. I want to show Back Arrow also. Can anyone tell me what I am doing wrong.

1条回答
Animai°情兽
2楼-- · 2019-03-19 16:41

You have to set it up this way:

ActionBar ab = getSupportActionBar();
ab.setDisplayHomeAsUpEnabled(true);

Hope that helps.

查看更多
登录 后发表回答