Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you remove the back button from a v7 toolbar on Android? [closed]

How do you remove the back button from a v7 toolbar on Android?

I highlighted the button that I'm trying to remove in the image below:

enter image description here

like image 499
Samadi Ilias Avatar asked Jan 05 '16 15:01

Samadi Ilias


People also ask

How do I get rid of the back arrow on my Android toolbar?

How do I get rid of the back arrow on my Android toolbar? getActionBar(). setDisplayShowHomeEnabled(false); //disable back button getActionBar(). setHomeButtonEnabled(false); In a older android phone, the back button is removed with these two code lines.

How do you get to the toolbar menu on Android?

Make a menu xml This is going to be in res/menu/main_menu . Right click the res folder and choose New > Android Resource File. Type main_menu for the File name. Choose Menu for the Resource type.


1 Answers

If you are using v7 Toolbar you can remove this button with this code :

if (getSupportActionBar() != null) {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(false);
}

you can read android here and here for more information. also this question may help

like image 166
Mohammad Fatemi Avatar answered Sep 27 '22 17:09

Mohammad Fatemi