我正在使用 ABS 版本。 4,我需要简单地更改除了操作模式关闭图标之外显示的默认“完成”文本,但我真的不知道该怎么做。
我认为文本需要可定制,至少有两个充分的理由:
是否可以自定义该文本?如果可以的话谁能告诉我该怎么做?
提前致谢。
EDIT
我找到了一个临时解决方法,我将其发布在以下内容中:
private TextView getActionModeCloseTextView() {
// ABS 4.0 defines action mode close button text only for "large" layouts
if ((getResources().getConfiguration().screenLayout &
Configuration.SCREENLAYOUT_SIZE_MASK) ==
Configuration.SCREENLAYOUT_SIZE_LARGE)
{
// retrieves the LinearLayout containing the action mode close button text
LinearLayout action_mode_close_button =
(LinearLayout) getActivity().findViewById(R.id.abs__action_mode_close_button);
// if found, returns its last child
// (in ABS 4.0 there is no other way to refer to it,
// since it doesn't have an id nor a tag)
if (action_mode_close_button != null) return (TextView)
action_mode_close_button.getChildAt(action_mode_close_button.getChildCount() - 1);
}
return null;
}
这就是我想出的方法。请NOTE它确实严重依赖于abs__action_mode_close_item.xml
ABS 4.0。
这适用于我的场景,但是,正如您所看到的,它不能被认为足以令人满意地将其提升为真正的“答案”,这就是为什么我只编辑了我之前的帖子。
希望对其他人有帮助,但我也希望有人可以分享更好、更干净的解决方案。
您可以使用主题来覆盖默认图标:
<item name="actionModeCloseDrawable">@drawable/navigation_back</item>
<item name="android:actionModeCloseDrawable">@drawable/navigation_back</item>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)