How to reset EditText after the action completes?

I want reset my EditText to return to an empty “space” or “tooltip” after clicking a button that completes the input operation from the EditText field.

My adventure with android is thus beckoning.

Greetings. Thank!

 //************-------------------SEND SMS----------------*********//
    btnSendSMS = (Button)findViewById(R.id.sms);
    btnSendSMS.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            sendSMS(dispEd.getText().toString(),msgEd.getText().toString());
        }

        private void sendSMS(String phoneNumber, String msg) {
            // TODO Auto-generated method stub
            SmsManager sms = SmsManager.getDefault();
            sms.sendTextMessage(phoneNumber, null, msg, null, null);
        }
    });
}

<EditText 
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:id="@+id/edit"/>

<EditText 
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:id="@+id/msg"/>
+5
source share
5 answers

try

editText.setText("");

Update: try setting the text as null

editText.setText(null);
+19
source

try the following:

EditText edit;
edit.setText(null);
+6
source

ediText.getText().clear();

.

+4

EditText -

name.setText("");

name.setText(null);

name.setText(null);
name.setHint("Enter First Team Name");

, , , -

name.setText(null);
+1

Perhaps what you are really looking for is android:hint="text"in your XML editor.

No additional code is required to achieve this behavior.

0
source

All Articles