Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>SIMPLE:</strong></p> <p>You want to set the text of the editText to an empty string or "".</p> <p><strong>IN DEPTH:</strong></p> <p>You need to import:</p> <pre><code>import android.widget.EditText; </code></pre> <p>Make sure you have this below your onCreate:</p> <pre><code>EditText field1 = (EditText) findViewById(R.id.editText1); EditText field2 = (EditText) findViewById(R.id.editText2); EditText field3 = (EditText) findViewById(R.id.editText3); EditText field4 = (EditText) findViewById(R.id.editText4); </code></pre> <p>Onclick you want to:</p> <pre><code>field1 .setText(""); field2 .setText(""); field3 .setText(""); field4 .setText(""); </code></pre> <p><strong>OVERKILL:</strong></p> <p>Here is how I would do it:</p> <pre><code>//START OF CUSTOM ALERTDIALOG// void openCustomDialog(){ AlertDialog.Builder customDialog = new AlertDialog.Builder(ACTIVITYNAMEHERE.this); customDialog.setTitle("TITLE HERE"); customDialog.setIcon(R.drawable.ic_action); //OPTIONAL Enter custom layout here if you want //LayoutInflater layoutInflater //= //(LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)//; //View view=layoutInflater.inflate(R.layout.mylayout,null); customDialog.setPositiveButton("Send", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface arg0, int arg1) { // TODO Auto-generated method stub //CODE FOR DATABASE YOURACTIVITYHERE.this.finish(); }}); customDialog.setNegativeButton("Reset Fields", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface arg0, int arg1) { // TODO Auto-generated method stub }}); //CODE I PROVIDED up top field1 .setText(""); field2 .setText(""); field3 .setText(""); field4 .setText(""); customDialog.setView(view); customDialog.show(); } //END OF CUSTOM ALERTDIALOG// </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload