How to set cursor position in EditText?

前端 未结 23 1589
广开言路
广开言路 2020-11-28 02:51

There are two EditText,while loading the page a text is set in the first EditText, So now cursor will be in the starting place of EditText, I want

23条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 03:20

    I have done this way to set cursor position to end of the text after updating the text of EditText programmatically here, etmsg is EditText

    etmsg.setText("Updated Text From another Activity");
    int position = etmsg.length();
    Editable etext = etmsg.getText();
    Selection.setSelection(etext, position);
    

提交回复
热议问题