Sandeep Kulkarni Sandeep Kulkarni - 1 year ago 202
Android Question

Android: Remove activity back Arrow

I created two blank activities in android studio and it looks like it adds back arrow by default. My

is parent of
. I want to maintain this hierarchy but want to get rid of back arrow.

enter image description here

Answer Source

If you're on API level 14 or above 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're using a support lib such as ActionbarSherlock, then use;

getSupportActionBar().setHomeButtonEnabled(false);      // Disable the button
getSupportActionBar().setDisplayHomeAsUpEnabled(false); // Remove the left caret
getSupportActionBar().setDisplayShowHomeEnabled(false); // Remove the icon
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download