What does ActionBar#setDefaultDisplayHomeAsUpEnabled in Android Support library?

烂漫一生 提交于 2019-12-20 03:08:43

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/36398448/what-does-actionbarsetdefaultdisplayhomeasupenabled-in-android-support-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!