0

I'm trying to show up action button at Toolbar while I'm at fragment (using 1 parent activity) like this: https://developer.android.com/training/implementing-navigation/ancestral.html

This up button must work as standard BackPress. But the main trouble that I've got only one activity with fragment manager and I cannot specify parent activity to it. (http://developer.android.com/training/implementing-navigation/ancestral.html#SpecifyParent)

In other, I using standard workflow:

  getMainActivity().getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_HOME_AS_UP);

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

but no result, only back arrow

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

0

To use Up button as standard Back button since there is only Activity in your Fragment. IF your Fragment has been added in BackStack then on back press it will get pop as standard nagivation.

If user presses the UP button then handle the Menu Home button and check is there any Fragment in Backstack then pop it.

popBackStack(int arg0, int arg1);

popBackStack(String arg0, int arg1);
strike
  • 1,031
  • 8
  • 24