How to set cursor position in EditText?

前端 未结 23 1499
广开言路
广开言路 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:27

    If you want to set the cursor after n character from right to left then you have to do like this.

    edittext.setSelection(edittext.length()-n);
    

    If edittext's text like

    version
    

    and you want to move cursor at 6th position from right

    Then it will move the cursor at-

        version 
                    ^
    

提交回复
热议问题