Dialog not getting recreated on orientation change
called using:
showDialog(DIALOG_LONG_CLICK_MENU_ID);
No problem with leaking the window on orientation change BUT when the activity gets re-created there is never a call to onCreateDialog or onPrepareDialog?
Don't know if it makes any difference but the activity is within a tab.
Any insight to possible causes massively appreciated!
@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);
}
精彩评论