安卓的EditText侦听光标移动光标、EditText

2023-09-07 13:10:02 作者:我会腻你何必i

我正在寻找一种方法来检测光标位置在的EditText 。我无法找到的文档中的任何至今。有没有人解决了这个了吗?

I'm looking for a way to detect a cursor position changed in an EditText. I couldn't find anything in the documentation so far. Has anyone solved this already?

推荐答案

您可以覆盖onSelectionChanged(SelStart的INT,INT selEnd),以收到通知的选择更改。如果光标被移动,这被称为以及(在此情况下SelStart的== selEnd)

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)