I have alert dialog with EditText on it. If user press positive button and EditText is empty the alert dialog is closed. Now I want to disable closing if user leaves Edit Text empty. How to do that?
This is code for alert dialog:
@Override
public void onClick(View v) {
AlertDialog.Builder wndInput = new AlertDialog.Builder(
MainActivity.this);
final EditText txtEditScraps = new EditText(MainActivity.this);
txtEditScraps.setInputType(InputType.TYPE_CLASS_PHONE);
wndInput.setTitle("Number of scraps:");
wndInput.setCancelable(false);
wndInput.setNegativeButton("CANCEL",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
wndInput.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
wndInput.setView(txtEditScraps);
wndInput.create().show();
}
First of all do small changes on last 2 lines of your code..
Means you just have reference the alert dialog.. and then add the following code.