首页 > 技术文章 > 修改EditText光标位置

zhudongfang 2015-03-11 12:08 原文

EditText有这么个便利方法

/**
 * Convenience for {@link Selection#setSelection(Spannable, int)}.
 */
public void setSelection(int index) {
    Selection.setSelection(getText(), index);
}

实际上调用的是这个 ```java /** * Move the cursor to offset index. */ public static final void setSelection(Spannable text, int index) { setSelection(text, index, index); } ```

推荐阅读