我有一个EditText对话框。 EditText在创建时已经填充。当用户将光标放置在文本的特定部分或其附近时,Toast将弹出。
我的问题是监听光标位置的变化。另一个post提出同样的问题,并且接受的解决方案是
You can override onSelectionChanged (int selStart, int selEnd) to get notified about selection changes. If the cursor is moved, this is called as well (in this case selStart == selEnd)
为我工作的解决方案
嗨,大师,谢谢你的回复,它的工作。
如果有人有兴趣,这是我做的详细的… *
第一步:创建子类
package com.example;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.EditText;
import android.widget.Toast;
public class EditTextCursorWatcher extends EditText {
public EditTextCursorWatcher(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
public EditTextCursorWatcher(Context context, AttributeSet attrs) {