Android Sherlock ActionBar Up button

actionbarsherlock, android, bitmap

Solution

Yes you have to implement `onOptionsItemSelected()`. The id for that button is `android.R.id.home`

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

    case android.R.id.home:
         // Do whatever you want, e.g. finish()
         break;

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

And I have two Items in my menu, they appear everywhere where I call OnCreateOptionsMenu

I'm not sure what the problem here is. Of course you should only implement `onCreateOptionsMenu()` and inflate that menu resource where you want it. Removing `onCreateOptionsMenu()` for all activities which are not supposed to have these options should work.

Problem

Near Stream there is a small arrow that takes u to the previous activity when clicked I want to make the same in my app, I used ``` getSupportActionBar().setDisplayHomeAsUpEnabled(true); ``` do I need to use `onOptionsItemSelected` ? The arrow is appearing, but nothing happens once clicked. And I have two Items in my menu, they appear everywhere where I call `OnCreateOptionsMenu` this is my item code where I want to to appear only in my last activity, How ? ``` <item android:id="@+id/bAbout" android:title="About" android:showAsAction="always"/> ```

Original source