0

I have a TabHost with 5 fragments. One of the Fragments leads to an Activity. When I press the back button in that activity it will lead me back to the fragment that started the activity, however if I press the home-up button in the actionbar it leads me back to the first tab's fragment. How can I make it go back to the fragment that called like the back button does when I press the home up button?

Max Kleine
  • 143
  • 1
  • 1
  • 11

1 Answers1

0

you need to override the action for the home button

in your activity -

@Override
public boolean onOptionsItemSelected(MenuItem item){
    if(item.getItemId() == android.R.id.home){
        onBackPressed();
        return true;
    }

    return super.onOptionsItemSelected(item);
}

this should cause the 2 behaviors (back button and home up) to be identical

Shooky
  • 1,269
  • 8
  • 16