Search code examples
androidandroid-edittextsettext

How to set an EditText to empty with a number input type


I have tried

editText.setText(""); 

however I get an error saying "" is not a valid integer. I have also tryed changing the input type to text setting the text to "" than changing the input type back to numbers but I get the same error.


Solution

  • Try this:

    editText.setText("0", BufferType.EDITABLE); /*// May be unecessary... */
    editText.getText().clear();
    

    You may need to set the buffer type to BufferType.EDITABLE first...