1. Are you ready for the Galaxy S20? Here is everything we know so far!

How can I Clear EditText and Retain New Typing

Discussion in 'Android Development' started by petecal, Mar 9, 2021.

  1. petecal

    petecal Member
    Thread Starter

    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?
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...