Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: disable action bar home button

We have a file manager-like application where we use the action bar home button as a "go up in the folder structure" action. If the user is at the top of the folder structure, the button should be disabled.

We set the home button as up when the user is within a sub folder. Shen we reach the top folder, we disable showing as up.

    // Update home
    actionBar.setDisplayHomeAsUpEnabled(hasParent);

the problem is that the button is still "enabled" in that the user can press it can see visual feedback that is was pressed. we want the action bar home button to be completely disabled in this case, when there is no parent folder.

I tried calling setDisplayShowHomeEnabled(), but does not disable the button but in stead this removes the home button completely.

Any ideas?

like image 558
Jeffrey Blattman Avatar asked Jun 04 '12 17:06

Jeffrey Blattman


People also ask

How do I disable the action bar?

If you want to hide Action Bar from the entire application (from all Activities and fragments), then you can use this method. Just go to res -> values -> styles. xml and change the base application to “Theme. AppCompat.

What is android Action Bar?

Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button.

How do I hide the back icon on my android toolbar?

Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.


1 Answers

Did you try setHomeButtonEnabled()? That is new to API Level 14, so you would have to skip it for Honeycomb tablets.

like image 127
CommonsWare Avatar answered Nov 02 '22 00:11

CommonsWare