Why is the up button present without setDisplayHomeAsUpEnabled()?

后端 未结 2 780
北荒
北荒 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.

提交回复
热议问题