0
我有一個應用程序與主要活動3按鈕。其中一個按鈕是一個重置按鈕,它可以下載,解析和填充sql數據庫,並基本上刪除用戶所做的所有更改。 單擊重置按鈕時,會彈出警報對話框以確認操作。如果用戶說'不'(即不想重置應用程序),則對話框關閉,主菜單再次可見。然後,當用戶點擊a按鈕查看填充了來自數據庫的項目的列表視圖時,除非重新啓動應用程序,否則不會發生這種情況。我不明白爲什麼會發生這種情況,LogCat中沒有任何錯誤。Android對話框關閉阻止列表視圖活動被填充
public void resetApp(View view) {
//TODO progress dialog
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
alertBuilder.setTitle("Confirm reset");
alertBuilder.setMessage("Are you sure you want reset the app and lose all changes?");
alertBuilder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// execute download task again
new DownloadTask().execute(getApplicationContext());
}
});
alertBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alert = alertBuilder.create();
alert.show();
CandidatesDatabaseHelper dbHelper = new CandidatesDatabaseHelper(getApplicationContext());
dbHelper.onReset(dbHelper.getWritableDatabase());
}
我們展示的代碼。 – wtsang02
嗯,發佈你的活動代碼? – jamis0n
對不起!我忘了添加它! – indecisivecoder