开发者

Android EditText how to start cursor pointer at the end of all characters- not end of first line

I have comment box using EditText and it has several lines. When user returns to the box they are alw开发者_如何学编程ays at end of line 1 rather than end of say line 3 if there are three lines total in the box. How can I fix this?


There might be easier ways perhaps, but one way is to use

editText.setSelection(editText.getText().length());

You can place this line inside an OnFocusChangeListener, or in a Create method.


You can also do this
final int selectionStart = editText.getSelectionStart(); final int selectionend = editText.getText().length();

Selection.setSelection(editText.getText(), selectionStart, selectionend);

Please make you are not calling setText after this because that will override the behavior.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜