Basic4android: How to clear a edit text from code?

2k views Asked by At

I have a problem with basic4anfroid.

I have two EditText fields and a button that performs mathematical operations. Everything works but I would need to reset the values ​​of the two EditTexts with a "Reset" button. Click event on the reset button, the code edittext1.text = 0 does nothing.

2

There are 2 answers

0
Erel On

You should set it to an empty string:

EditText1.Text = ""
0
mikeward2534 On

Edittext1.text is looking for a string not an integer. 0 is an integer. If you want the number 0 to be in the Edittext field, then you would use the following code:

edittext1.text = "0"

Notice the quotation marks around the 0, this makes it a string not an integer. Also if someone answered your question, please mark it as accepted.