代碼無法正常工作。請幫幫我。它打印替換所有字符串,但進一步的代碼沒有運行。機器人警告框不起作用
當我調試這個時,代碼中沒有錯誤。它會顯示警告框的代碼。
if(count>0)
{
System.out.println("replace all string name ");
// final Intent intent_ul=new Intent(this, UploadExcel.class);
AlertDialog.Builder alertDialogBuilder_ue = new AlertDialog.Builder(this);
alertDialogBuilder_ue.setTitle("Alert!!");
alertDialogBuilder_ue
.setMessage("Are you sure you want to Replace all the data related to this style ? ")
.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
mySQLiteAdapter.openToWrite();
mySQLiteAdapter.delete_style_measurement(style_no);
Log.d("","yes click");
count=0;
mySQLiteAdapter.close();
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
Log.d("","No click");
count++;
dialog.cancel();
// startActivity(intent_ul);
//finish();
}
});
}
你能解釋一下'AlertDialog alertDialog = alertDialogBuilder_ue.create();'行?什麼是alertDialogBuilder_ue –
alertDialogBuilder_ue是一個使用它可以創建alertdialog的構建器對象,不能直接使用builder對象來顯示alertdialog。因此,您必須首先獲取AlerDialog的實例,然後調用它的show()。 –