Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Back Arrow in Action bar Sherlock is not displaying

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.

like image 370
Androider Avatar asked Dec 13 '12 11:12

Androider


People also ask

What is the Action bar?

Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button.


1 Answers

You have to set it up this way:

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

Hope that helps.

like image 90
Adrián Rodríguez Avatar answered Nov 10 '22 10:11

Adrián Rodríguez