android: how to remove the back/home button in the action bar

后端 未结 9 1581
一向
一向 2020-12-29 02:20

I am having difficulties trying to remove the back/home button from the action bar.

 getActionBar().setDisplayShowHomeEnabled(false);   //disable back button         


        
9条回答
  •  心在旅途
    2020-12-29 03:06

    If you're on API level 14 or above and are not using ActionbarSherlock, this code in onCreateOptionsMenu will disable the up button, remove the left caret, and remove the icon:

    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
    }
    

    source: https://stackoverflow.com/a/24967862/2887103

提交回复
热议问题