Skip to content

Instantly share code, notes, and snippets.

@JS-Zheng
Created August 21, 2016 09:04
Show Gist options
  • Save JS-Zheng/9843d2005ec277e1947d92eedd76fce5 to your computer and use it in GitHub Desktop.
Save JS-Zheng/9843d2005ec277e1947d92eedd76fce5 to your computer and use it in GitHub Desktop.
focusLastCharOfEditText
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