Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset EditText after an action has been completed?

I would like to reset my EditText back to an empty "space" or a "hint" after a button has pressed that would have completed an activity with input from the EditText field.

My adventure with android thus beckons.

Cheers. Thank you !!

 //************-------------------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"/>
like image 644
Vinoth Avatar asked Aug 30 '11 10:08

Vinoth


1 Answers

you should try

editText.setText("");

Update: Try setting text as null

editText.setText(null);
like image 177
Adil Soomro Avatar answered Sep 27 '22 19:09

Adil Soomro