Created
April 30, 2013 09:49
-
-
Save daichan4649/5487732 to your computer and use it in GitHub Desktop.
エンター押下時にIME閉じる (for Android)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// EditText に listener を設定 | |
// [EditText].setOnEditorActionListener(mEditorActionListener); | |
private OnEditorActionListener mEditorActionListener = new OnEditorActionListener() { | |
@Override | |
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { | |
if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { | |
hideIME(v); | |
} | |
return false; | |
} | |
private void hideIME(final TextView v) { | |
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); | |
imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY); | |
imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment