• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How can I Clear EditText and Retain New Typing

petecal

Member
I have a single EditText view. It normally has text in it that represents a number. I would like the user to be able to tap in the view and have the contents be cleared. Then the user puts in a new number and taps "Done" on the keyboard. The keyboard should go away and the EditText should retain the new value for future access.

If I just let the user tap in the EditText the "old" value will still be there and the user will have to delete it one character at a time before entering a new value. Then tap Done on the keyboard.

I tried an OnClick that:
thisEditText.setText("");
This will clear all the text and allow the user to enter new text. But when the user is finished the user has to tap the "Done" button on the keyboard. When that happens the EditText is cleared again and the keyboard remains. There doesn't seem any way out of this state.

Any ideas?
 
Back
Top Bottom