Delete text in Edittext field

Asked

Viewed 1,401 times

1

How do I delete a text after sending.

    enviar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String value = editText.getText().toString();

            //push creates a unique id in database
            demoRef.push().setValue(value);

            Toast.makeText(TelaPolicia.this,
                    "Enviando", Toast.LENGTH_LONG).show();



        }
    });

    <EditText
        android:id="@+id/editescrever"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/btnenviar"
        android:layout_alignParentStart="true"
        android:layout_marginBottom="31dp"
        android:layout_marginStart="19dp"
        android:ems="10"
        android:hint="Escreva o incidente"
        android:inputType="textPersonName"
        android:textSize="18sp" />

    <Button
        android:id="@+id/btnenviar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="123dp"
        android:text="Enviar" /> 
  • editText.setText("");

  • editText.setText(""); is the right answer, I do not understand why @Antonios.Junior put as comment.

  • I’ll put it in answer, it was bad!

1 answer

2


Set your Edittext to the value you want after your send action. In your case it would be:

editText.setText("");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.