简体   繁体   English

Android:将新值设为EditText为空

[英]Android: Make EditText empty when new value

I Want to make my EditText empty when you put a new value. 当您输入新值时,我想使我的EditText空。 If I use a onClickListener I need first to focus and then to click (Double click), if I use onFocusChangeListener it is already deleting when click another EditText . 如果我使用一个onClickListener我需要先对焦,然后点击(双击),如果我用onFocusChangeListener它已经当单击另一个删除EditText

Does someone know a other way to achieve this (When first click == empty)? 有人知道实现此目的的另一种方法(第一次单击==空时)吗?

Thanks in advance! 提前致谢!

Don't make things complicated. 不要让事情变得复杂。 Simply set android:selectAllOnFocus="true" to your EditText . 只需将android:selectAllOnFocus="true"为您的EditText So, when the user types-in some text and later click the text box, all the text inside will be highlighted - allowing user to type-in new text from scratch. 因此,当用户键入一些文本并随后单击文本框时,其中的所有文本都将突出显示-允许用户从头开始输入新文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM