0
我已經把一個布爾條件裏面的Alertdialog「確定」按鈕..但該條件似乎並沒有工作..在頂部..即使在評論dialog.dismiss()後。 .the警告對話框時,我用了一段檢查仍然被駁回..AlertDialog在Android不尋常的行爲
這是警告對話框的小代碼..
ab.setCancelable(false).setPositiveButton("Add", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(ValidationsForNewCelebration()){
str1=et1.getText().toString();
str2=et2.getText().toString();
// AddNewTask anct=new AddNewTask();
// anct.execute();
// dialog.dismiss();
} else {
}
}
}
,這我的布爾條件代碼..
protected boolean ValidationsForBlankFields(){
boolean allFieldsValid=true;
if(et1.getText().toString().length()<=0){
Toast.makeText(StartingActivity.this, "Field should not be kept Blank ", Toast.LENGTH_SHORT).show();
//return false;
allFieldsValid=false;
}
else if(et2.getText().toString().length()<=0){
Toast.makeText(StartingActivity.this, "Field should not be kept Blank ", Toast.LENGTH_SHORT).show();
//return false;
allFieldsValid=false;
}
else if(tv1.getText().toString().length()<=0){
Toast.makeText(StartingActivity.this, "Please fill up the Blank Field", Toast.LENGTH_SHORT).show();
allFieldsValid=false;
}
else if(tv2.getText().toString().length()<=0){
Toast.makeText(StartingActivity.this, "Please fill up the Blank Field", Toast.LENGTH_SHORT).show();
allFieldsValid=false;
}
if(!allFieldsValid){
return false;
} else {
return true;
}
}
tv1
,* tv2*
是兩個textviews
,而et1
和et2
是edittext
。條件是檢查他們是否是empty or not
。
感謝lot..will try..and任何想法,爲什麼alertdialog被駁回,即使dialog.dismiss()被註釋掉? ? – AndroidMech
@MarcoAcierno即使我認爲這是我的錯誤..即使當我點擊確定按鈕的AlertDialog ..對話框被駁回.. – AndroidMech
http://stackoverflow.com/questions/2620444/how-to-防止-A-對話框的從閉-時-A-按鈕是點擊的 –