Why is the up button present without setDisplayHomeAsUpEnabled()?

后端 未结 2 741
北荒
北荒 2021-02-13 21:16

According to Google\'s document, getActionBar().setDisplayHomeAsUpEnabled(true) is needed to show the up button. I created a bare-bone activity using the wizard in

相关标签:
2条回答
  • 2021-02-13 21:59

    I described all possible combinations below and their outcomes:

    1. You have both android:parentActivityName=".MyActivityand this getActionBar().setDisplayHomeAsUpEnabled(true); - back button appears and it works;
    2. You only have this android:parentActivityName=".MyActivity - back button appears and it works, the same as above;
    3. You only have this getActionBar().setDisplayHomeAsUpEnabled(true);, - back button appears but clicking on it doesn't go anywhere;
    4. You have set the parameter to false in this getActionBar().setDisplayHomeAsUpEnabled(false);, even though you have this android:parentActivityName=".MyActivity in the manifest, the back button doesn't show up.

    That's how this works my friend.

    0 讨论(0)
  • 2021-02-13 22:04

    When you specify a parentActivityName in your AndroidManifest, Acitivty will check for that and automatically enable the "up" affordance if it's present.

    0 讨论(0)
提交回复
热议问题