ActionBarSherlock (ABS): how to customize the text of action mode close item?
actionbarsherlock, android, android-actionbar
Solution
You can use a theme to override the default icon:
<item name="actionModeCloseDrawable">@drawable/navigation_back</item>
<item name="android:actionModeCloseDrawable">@drawable/navigation_back</item>
Problem
I'm using ABS vers. 4 and I need to simply change the default "Done" text that is displayed besides the action mode close icon, but I really can't figure out how to do it. I think that text needs to be customizable for at least two good reasons: "Done" is not appropriate for all contexts (e.g. "Cancel" could be more appropriate, and I've seen some apps, such as the "My Files" app on Galaxy Tab, use it) "Done" needs to be localized according to the user's language Is it possible to do customize that text? If so can anyone tell me how to do it? Thanks in advance. EDIT I've found a temporary workaround, that I post in the following: ``` 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; } ``` That's the method I came up with. Please NOTE that it does heavily rely upon the structure of the `abs__action_mode_close_item.xml` of ABS 4.0. This works for my scenario, but, as you can see, it cannot be considered sufficiently satisfying to promote it to a real "answer", that's why I only edited my previous post. Hope that helps someone else, but I also hope that someone could share a better and cleaner solution.