Is there a way to reset the edittext value without setting text like:
((EditText) findViewById(R.id.yoursXmlId)).setText(\"\");
EDI
I had a case where a Samsung device was not blanking out text with setText(""), so I used:
String BLANK = "\u0020"; // space character
setText (BLANK);
and it worked this way. It may have been a font issue.
if anyone is finding the selected answer not working please try with
editText.post(() -> editText.getText().clear());
or
editText.post(new Runnable() {
@Override
public void run() {
editText.getText().clear();
}
});
Another option is: EditText.getText().clear(); But you'll have to cast anyway:
((EditText) findViewById(R.id.yoursXmlId)).getText().clear();
you can use following way
Kotlin:
myEditText.text.clear()
Java:
EditText myEditText = ((EditText) findViewById(R.id.yoursXmlId));
myEditText.getText().clear()
A function for that would be:
fun setTextViewEmpty(textView: TextView){
(textView as EditText ).text.clear() }
inspired by this