I have couple of dialogs where the user can go back and forth. One of which is a custom dialog with an editText. I want the description editText to be always blank. I used
description.setText("");
When I edit the description text to for instance "abcd", move back to the DIALOG_THREE and then to DIALOG_FOUR. description.setText(""); is not called. The changed text "abcd" remains on the edit text. Can experts please suggest how I can set it to blank when I move from one dialog to another.
@Override
@Deprecated
protected Dialog onCreateDialog(int id) {
Dialog dialog = null;
AlertDialog.Builder builder = new AlertDialog.Builder(this,
android.R.style.Theme_DeviceDefault_Light_DarkActionBar);
switch (id) {
case DIALOG_THREE:
builder.setCancelable(false);
builder.setTitle("Incident Catagory");
builder.setSingleChoiceItems(incidentCatagory, -1,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
builder.setPositiveButton("next",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
showDialog(DIALOG_FOUR);
}
});
builder.setNegativeButton("Back",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
showDialog(DIALOG_TWO);
}
});
return builder.create();
case DIALOG_FOUR:
LayoutInflater inflaterFour = this.getLayoutInflater();
final View inflatorFour = inflaterFour.inflate(
R.layout.dialog_incidents_four_description, null);
builder.setView(inflatorFour);
description = (EditText) inflatorFour.findViewById(R.id.etDescription);
description.setText("");
builder.setPositiveButton("Next", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
showDialog(DIALOG_FIVE);
String desc = description.getText().toString();
}
});
builder.setNegativeButton("Back", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
showDialog(DIALOG_THREE);
}
});
return builder.create();
Thank you very much.