Ugh, nevermind -- a quick look at the Android sources solved this
easily.

For the record, this seems to be the right way to change a setting in
a preference screen:
                CheckBoxPreference p = (CheckBoxPreference)findPreference
("foo_enable");
                p.setChecked(false);

Spiros.


On Feb 10, 7:03 pm, Spiros <[email protected]> wrote:
> Hi,
>
> I have a checkbox preference which, when set for the first time, may
> trigger a long-running operation.  I want to get the user's explicit
> consent before starting this operation.  However, if the user hits
> cancel, then the preference should remain unchecked.
>
> I'm using a preference activity and register an onPreferenceChanged()
> handler for the checkbox preference in question, which shows an alert
> dialog (and returns true, so the preference *will* be set before the
> dialog pops up).
>
> I tried doing something like this in the AlertDialog that asks for
> user confirmation, to revert that preference change if he clicks
> cancel:
>
> [....]
> .setNegativeButton(R.string.cancel_button, new
> DialogInterface.OnClickListener() {
>         @Override
>         public void onClick (DialogInterface dialog, int which) {
>                 Editor e = getPreferenceScreen().getEditor();
>                 e.putBoolean("foo_enable", false);
>                 e.commit();
>                 SettingsActivity.this.onContentChanged();
>         }
>
> })
>
> but it doesn't quite have the desired effect: the "foo_enabled"
> preference remains checked.
>
> AFAIK there are no blocking modal dialogs in Android.  Should I
> perhaps be using something other than onPreferenceChanged() for this?
> Any suggestions would be appreciated!
>
> Thanks,
> Spiros
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to