Hi, folks!
I'm trying to check the value of the EditText inside my AlertDialog, so that I can prevent the user from entering nothing in the EditText.
For some reason, when I use the code below and press ok I return to List, but i want after "Name required" dialog leave in "Rename Contact" dialog.
I'm trying to check the value of the EditText inside my AlertDialog, so that I can prevent the user from entering nothing in the EditText.
For some reason, when I use the code below and press ok I return to List, but i want after "Name required" dialog leave in "Rename Contact" dialog.
Code:
case Constants.RENAME_CONTACT:
AlertDialog dialog = new AlertDialog.Builder(context)
.setTitle("Rename Contact")
.setMessage("Rename Contact:")
.setView(renameInput)
.setPositiveButton("Save", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!TextUtils.isEmpty(renameInput.getText())){
contactToRename.setName(renameInput.getText().toString());
fp.update(contactToRename);
refreshList(contactFilter.getText().toString(), sortAsc);
}
else{
new AlertDialog.Builder(context)
.setTitle("Name required")
.setMessage("Name field must be completed.")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
}
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// do nothing