开发者

Android :Alert Dialog, Cancel Button

开发者 https://www.devze.com 2023-02-08 09:35 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消