How to set cursor position in EditText?

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

    some time edit text cursor donot comes at particular position is if we directly use editText.setSelection(position); . In that case you can try

    editText.post(new Runnable() {
                    @Override
                    public void run() {
                        editText.setSelection(string.length());
                    }
                });
    

提交回复
热议问题