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); } ```