setDisplayHomeAsUpEnabled和setHomeButtonEnabled有什么区别? [英] What is the difference between setDisplayHomeAsUpEnabled and setHomeButtonEnabled?
问题描述
我想启用操作栏中的主页按钮.我正在使用此代码:
I want to enable the home button in the Action bar. I'm using this code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
actionbar.setHomeButtonEnabled(true);
actionbar.setDisplayHomeAsUpEnabled(true);
}
在这种情况下,我使用setHomeButtonEnabled
和setDisplayHomeAsUpEnabled
在ActionBar中的图标上添加后退标记.如果我仅使用setDisplayHomeAsUpEnabled
,也可以使用吗?是否需要将setHomeButtonEnabled
设置为true?
In this I'm using setHomeButtonEnabled
and setDisplayHomeAsUpEnabled
to put a back mark at icon in ActionBar. If I use only setDisplayHomeAsUpEnabled
then also will it work? Is there a need to set setHomeButtonEnabled
to true?
两者之间有什么区别?
推荐答案
对于您想要做的事情,actionBar.setDisplayHomeAsUpEnabled(true)
就足够了.
区别在于:
actionBar.setHomeButtonEnabled(true)
只会使图标可点击,图标背景上的颜色作为点击的反馈.
actionBar.setDisplayHomeAsUpEnabled(true)
将使图标可单击,并在图标左侧添加<
.
For what you want to do, actionBar.setDisplayHomeAsUpEnabled(true)
is enough.
For the difference :actionBar.setHomeButtonEnabled(true)
will just make the icon clickable, with the color at the background of the icon as a feedback of the click.
actionBar.setDisplayHomeAsUpEnabled(true)
will make the icon clickable and add the <
at the left of the icon.
这篇关于setDisplayHomeAsUpEnabled和setHomeButtonEnabled有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!