且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android:在当前位置将文本插入EditText

更新时间:2023-01-28 08:06:15

尝试使用 EditText.getSelectionStart() 获取光标的当前位置.然后你可以使用 String.subString 来获取光标前后的文本,并在中间插入你的文本.

Try using EditText.getSelectionStart() to get the current position of the cursor. Then you can use String.subString to get the text before and after the cursor and insert your text in the middle.