如何清除EditText中的选择? [英] How to clear the selection in an EditText?

查看:114
本文介绍了如何清除EditText中的选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以编程方式从EditText中删除选择?我尝试过:

How do you programmatically remove the selection from an EditText? I've tried:

myEditText.setSelection(selectionEnd);

但这只是在当前选择的结尾创建一个长度为0的选择.我也尝试过Selection.removeSelection(mySpannable),它只是在文本的开头放置一个空的选择.

but that just creates a selection of 0 length at the end of the current selection. I've also tried Selection.removeSelection(mySpannable), and it just puts an empty selection at the beginning of the text.

推荐答案

调用myEditText.clearFocus();.我认为这就是您所需要的

Calling myEditText.clearFocus();. I think that's what you need

这篇关于如何清除EditText中的选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆