【发布时间】:2013-05-21 10:50:40
【问题描述】:
我正在尝试自定义与ActionBar 的向上按钮关联的“向上导航”默认 contentDescription(我正在使用 ActionBarSherlock)。
来自ActionBarView的来源:
public void setHomeButtonEnabled(boolean enable) {
mHomeLayout.setEnabled(enable);
mHomeLayout.setFocusable(enable);
// Make sure the home button has an accurate content description for accessibility.
if (!enable) {
mHomeLayout.setContentDescription(null);
} else if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
mHomeLayout.setContentDescription(mContext.getResources().getText(
R.string.abs__action_bar_up_description));
} else {
mHomeLayout.setContentDescription(mContext.getResources().getText(
R.string.abs__action_bar_home_description));
}
}
所以关键是如何获得对mHomeLayout 的引用。 getWindow().getDecorView().findViewById(android.R.id.home) 不起作用,因为它正在返回一个 ImageView。
我该怎么办?
谢谢 ;)
【问题讨论】:
标签: android android-actionbar actionbarsherlock accessibility