YesNoPreferencepublic class YesNoPreference extends android.preference.DialogPreference The {@link YesNoPreference} is a preference to show a dialog with Yes and No
buttons.
This preference will store a boolean into the SharedPreferences. |
Fields Summary |
---|
private boolean | mWasPositiveResult |
Constructors Summary |
---|
public YesNoPreference(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)
super(context, attrs, defStyleAttr, defStyleRes);
| public YesNoPreference(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)
this(context, attrs, defStyleAttr, 0);
| public YesNoPreference(android.content.Context context, android.util.AttributeSet attrs)
this(context, attrs, com.android.internal.R.attr.yesNoPreferenceStyle);
| public YesNoPreference(android.content.Context context)
this(context, null);
|
Methods Summary |
---|
public boolean | getValue()Gets the value of this preference.
return mWasPositiveResult;
| protected void | onDialogClosed(boolean positiveResult)
super.onDialogClosed(positiveResult);
if (callChangeListener(positiveResult)) {
setValue(positiveResult);
}
| protected java.lang.Object | onGetDefaultValue(android.content.res.TypedArray a, int index)
return a.getBoolean(index, false);
| protected void | onRestoreInstanceState(android.os.Parcelable state)
if (!state.getClass().equals(SavedState.class)) {
// Didn't save state for us in onSaveInstanceState
super.onRestoreInstanceState(state);
return;
}
SavedState myState = (SavedState) state;
super.onRestoreInstanceState(myState.getSuperState());
setValue(myState.wasPositiveResult);
| protected android.os.Parcelable | onSaveInstanceState()
final Parcelable superState = super.onSaveInstanceState();
if (isPersistent()) {
// No need to save instance state since it's persistent
return superState;
}
final SavedState myState = new SavedState(superState);
myState.wasPositiveResult = getValue();
return myState;
| protected void | onSetInitialValue(boolean restorePersistedValue, java.lang.Object defaultValue)
setValue(restorePersistedValue ? getPersistedBoolean(mWasPositiveResult) :
(Boolean) defaultValue);
| public void | setValue(boolean value)Sets the value of this preference, and saves it to the persistent store
if required.
mWasPositiveResult = value;
persistBoolean(value);
notifyDependencyChange(!value);
| public boolean | shouldDisableDependents()
return !mWasPositiveResult || super.shouldDisableDependents();
|
|