我试图自定义与向上按钮ActionBar
(我使用ActionBarSherlock)关联的“向上导航”默认contentDescription
。为ActionBar的向上按钮设置contentDescription
从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。
我该怎么办?
感谢;)