Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ActionBar#setDefaultDisplayHomeAsUpEnabled in Android Support library?

I know what setDisplayHomeAsUpEnabled does, but what is setDefaultDisplayHomeAsUpEnabled for I can only wonder. No documentation found, cannot find anything except it is being used.

like image 763
arenaq Avatar asked Apr 04 '16 09:04

arenaq


People also ask

What is difference between toolbar and ActionBar?

The Toolbar is basically the advanced successor of the ActionBar. It is much more flexible and customizable in terms of appearance and functionality. Unlike ActionBar, its position is not hardcoded i.e., not at the top of an activity.

Where is ActionBar in Android?

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.

What is action bar windows Android?

The ActionBar, now known as the App Bar, is a consistent navigation element that is standard throughout modern Android applications. The ActionBar can consist of: An application icon. An "upward" navigation to logical parent. An application or activity-specific title.


1 Answers

This method is only available in the Support Action Bar, not in the "native" ActionBar class available since Android 3. More importantly, it is annotated with @hide in the source, meaning it is not part of the official API for third-party developers. That is why it is nowhere documented by Google. You should just not use it.

Having a deeper look into the sources, I found the method implemented in WindowDecorActionBar:

public void setDefaultDisplayHomeAsUpEnabled(boolean enable) {
    if (!mDisplayHomeAsUpSet) {
        setDisplayHomeAsUpEnabled(enable);
    }
}

So basically it does exactly the same as using setDisplayHomeAsUpEnabled, but only if the value has not yet been set manually using the said function.

tldr: you should always use setDisplayHomeAsUpEnabled and ignore the default method.

like image 65
Phoca Avatar answered Sep 28 '22 18:09

Phoca