I want my code to check if what is written in my dialog contains a certain string and if not to be unable to close the dialog. Now when I press the okay button the dialog disappears despite the fact the toast appears, so I guess I have done something wrong with setCancelable
             protected void showInputDialog() {
    // get prompts.xml view
    LayoutInflater layoutInflater = LayoutInflater.from(MainActivity.this);
    View promptView = layoutInflater.inflate(R.layout.url, null);
    final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this, AlertDialog.THEME_HOLO_DARK);
    alertDialogBuilder.setView(promptView);
    final EditText editText = (EditText) promptView.findViewById(R.id.Button01);
    alertDialogBuilder.setTitle("Enter URL");
   // alertDialogBuilder.setCustomTitle("Enter URL");
   // alertDialogBuilder.setIcon(R.drawable.icon);
    alertDialogBuilder.setCancelable(false);
    alertDialogBuilder.setPositiveButton("DONE", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            String value = editText.getText().toString();
            if (value.contains("www.facebook.com/")) {
                //Toast.makeText(getBaseContext(), "You didn't enter the Name",Toast.LENGTH_SHORT).show();
               // alertDialogBuilder.setCancelable(false);
            }
            else {
                Toast.makeText(getBaseContext(), "You didn't enter the Name",Toast.LENGTH_SHORT).show();
                alertDialogBuilder.setCancelable(false);
            }
        }
    });
    // create an alert dialog
    AlertDialog alert = alertDialogBuilder.create();
    alert.show();
}
Any suggestions how to fix that?
edit: I have posted the whole function although I don't think it will help you
 
     
     
    