Better way to get all the text in an EditText from an InputConnection?

我是研究僧i 提交于 2019-12-02 23:42:28
Niranj Patel

Here is also another way to do it:

inputConnection.performContextMenuAction(android.R.id.selectAll);
CharSequence sData =  inputConnection.getSelectedText(0);

My solution is to use getExtractedText(). I am not sure if this has some limitations, but has worked for me so far.

CharSequence currentText = inputConnection.getExtractedText(new ExtractedTextRequest(), 0).text;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!