在使用EditText的时候,使用EditText.setText()设置内容之后,光标默认是在第一个位置。
为了使用方便,应该需要把光标移至最后。
使用EditText.setSelection()方法可以设置光标位置。
如果要设置到最后,代码如下:
String text = "This is a string"
editText.setText(text);
editText.setSelection(text.length());
在使用EditText的时候,使用EditText.setText()设置内容之后,光标默认是在第一个位置。
为了使用方便,应该需要把光标移至最后。
使用EditText.setSelection()方法可以设置光标位置。
如果要设置到最后,代码如下:
String text = "This is a string"
editText.setText(text);
editText.setSelection(text.length());