Skip to content

Instantly share code, notes, and snippets.

@alvinsj
Created May 25, 2012 09:42
Show Gist options
  • Save alvinsj/2786995 to your computer and use it in GitHub Desktop.
Save alvinsj/2786995 to your computer and use it in GitHub Desktop.
ActionBarSherlock ActionView EditText bugfix
searchActionItem.setOnActionExpandListener(new
OnActionExpandListener() {
public boolean onMenuItemActionExpand(MenuItem item) {
searchText.post(new Runnable() {
public void run() {
searchText.requestFocusFromTouch();
InputMethodManager imm =
(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(searchText, 0);
}
});
return true;
}
public boolean onMenuItemActionCollapse(MenuItem item) {
InputMethodManager imm =
(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(searchText.getWindowToken(), 0);
searchText.post(new Runnable() {
public void run() {
searchText.clearFocus();
}
});
return true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment