Created
August 21, 2016 09:04
-
-
Save JS-Zheng/9843d2005ec277e1947d92eedd76fce5 to your computer and use it in GitHub Desktop.
focusLastCharOfEditText
This file contains hidden or 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
public void focusLastCharOfEditText(View view) { | |
if (view instanceof EditText) { | |
EditText editText = (EditText) view; | |
int pos = editText.getText().length(); | |
editText.setSelection(pos); | |
editText.requestFocusFromTouch(); | |
InputMethodManager imm = (InputMethodManager)getContext().getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); | |
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); | |
} else { | |
Logger.e("This view is not a EditText."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment