Android: removing activity back Arrow

I created two empty operations in android studio, and it looks like it is adding the default arrow back. My MainActivity is the parent of ResultActivity . I want to keep this hierarchy, but I want to get rid of the back arrow.

enter image description here

+5
source share
3 answers

If you are at API level 14 or higher and are not using ActionbarSherlock, this code in onCreateOptionsMenu should disable the up button;

 ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(false); // Disable the button actionBar.setDisplayHomeAsUpEnabled(false); // Remove the left caret actionBar.setDisplayShowHomeEnabled(false); // Remove the icon } 

If you are using lib support such as ActionbarSherlock, use <; p>

 getSupportActionBar().setHomeButtonEnabled(false); // Disable the button getSupportActionBar().setDisplayHomeAsUpEnabled(false); // Remove the left caret getSupportActionBar().setDisplayShowHomeEnabled(false); // Remove the icon 
+11
source
 getActionBar().setDisplayHomeAsUpEnabled(false); 
+2
source

I know this is an old question, but I came across this now and had to take additional steps to remove the back arrow.

So in addition to this part of the code, as indicated, the correct answer

 getActionBar().setDisplayHomeAsUpEnabled(false); 

You will also need to remove the parent-child relationship in the AndroidManifest.xml file. Your activity should not have the following entry

 android:parentActivityName 

May help someone else who stumbles over it.

0
source

All Articles