使用:
调用的ShowDialog(DIALOG_LONG_CLICK_MENU_ID);
在方向更改时泄漏窗口没有问题但是当重新创建活动时,永远不会调用onCreateDialog或onPrepareDialog?
不知道它是否有任何区别,但活动是在标签内。
对可能的任何见解都会受到大力赞赏!
@Override
protected Dialog onCreateDialog(int id) {
Dialog dialog;
CURRENT_DIALOG = id;
switch(id) {
case DIALOG_LONG_CLICK_MENU_ID:
dialog = displayItemLongClickMenu();
break;
default:
CURRENT_DIALOG = DIALOG_NONE_ID;
dialog = null;
break;
}
return dialog;
}
private Dialog displayItemLongClickMenu() {
AlertDialog alertDialog;
AlertDialog.Builder builder;
builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.activity_item_dialog_title);
// save index and top position
mIndex = getListView().getFirstVisiblePosition();
View vLC = getListView().getChildAt(0);
mTop = (vLC == null) ? 0 : vLC.getTop();
builder.setItems(new String[]{ getString(R.string.delete)},
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
final PomodoroApp pA = ((PomodoroApp)getApplicationContext());
switch (which){
case DELETE_ID:
mDbHelper.deleteActivity(mItemListDialogId);
refactorToDoList();
dialog.dismiss();
break;
default:
break;
}
}
});
alertDialog = builder.create();
alertDialog.setCancelable(true);
return(alertDialog);
}