I have a dialog with 开发者_如何学运维five CheckedTextView
. When I open dialog and Click on some CheckBoxes and than I click Cancel Button. But when I open dialog again. The changes made is saved. Why? How to cancel what I clicked when I press Cancel button ?
Android creates the dialog box just once, and then reuses it instead of recreating it. Thus, your onCreateDialog
method is called only once. The second time, you get the same dialog, with the same check boxes in the same state.
To ensure that the dialog contains the correct data, override onPrepareDialog
. This gets called every time right before the dialog is shown. From here, you can set the check boxes to the desired state.
精彩评论