Skip to content Skip to sidebar Skip to footer

Why Is The Up Button Present Without Setdisplayhomeasupenabled()?

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 Eclipse and spec

Solution 1:

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

Solution 2:

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.

Post a Comment for "Why Is The Up Button Present Without Setdisplayhomeasupenabled()?"