Build 1.0_r1(from source)

android.preference
Class CheckBoxPreference

java.lang.Object
  extended by android.preference.Preference
      extended by android.preference.CheckBoxPreference
All Implemented Interfaces:
OnDependencyChangeListener, Comparable<Preference>

public class CheckBoxPreference
extends Preference

The CheckBoxPreference is a preference that provides checkbox widget functionality.

This preference will store a boolean into the SharedPreferences.


Nested Class Summary
 
Nested classes/interfaces inherited from class android.preference.Preference
Preference.BaseSavedState, Preference.OnPreferenceChangeInternalListener, Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener
 
Field Summary
 
Fields inherited from class android.preference.Preference
DEFAULT_ORDER
 
Constructor Summary
CheckBoxPreference(Context context)
           
CheckBoxPreference(Context context, AttributeSet attrs)
           
CheckBoxPreference(Context context, AttributeSet attrs, int defStyle)
           
 
Method Summary
 boolean getDisableDependentsState()
          Returns whether dependents are disabled when this preference is on (true) or when this preference is off (false).
 CharSequence getSummaryOff()
          Returns the summary to be shown when unchecked.
 CharSequence getSummaryOn()
          Returns the summary to be shown when checked.
 boolean isChecked()
          Returns the checked state.
protected  void onBindView(View view)
          Binds the created View to the data for the preference.
protected  void onClick()
          Processes a click on the preference.
protected  Object onGetDefaultValue(TypedArray a, int index)
          Called when Preference is being inflated and the default value attribute needs to be read.
protected  void onRestoreInstanceState(Parcelable state)
          Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by Preference.onSaveInstanceState().
protected  Parcelable onSaveInstanceState()
          Hook allowing a preference to generate a representation of its internal state that can later be used to create a new instance with that same state.
protected  void onSetInitialValue(boolean restoreValue, Object defaultValue)
          Implement this to set the initial value of the Preference.
 void setChecked(boolean checked)
          Sets the checked state and saves it to the SharedPreferences.
 void setDisableDependentsState(boolean disableDependentsState)
          Sets whether dependents are disabled when this preference is on (true) or when this preference is off (false).
 void setSummaryOff(CharSequence summary)
          Sets the summary to be shown when unchecked.
 void setSummaryOff(int summaryResId)
           
 void setSummaryOn(CharSequence summary)
          Sets the summary to be shown when checked.
 void setSummaryOn(int summaryResId)
           
 boolean shouldDisableDependents()
          Should return whether this preference's dependents should currently be disabled.
 
Methods inherited from class android.preference.Preference
callChangeListener, compareTo, dispatchRestoreInstanceState, dispatchSaveInstanceState, findPreferenceInHierarchy, getContext, getDependency, getEditor, getFilterableStringBuilder, getId, getIntent, getKey, getLayoutResource, getOnPreferenceChangeListener, getOnPreferenceClickListener, getOrder, getPersistedBoolean, getPersistedFloat, getPersistedInt, getPersistedLong, getPersistedString, getPreferenceManager, getSharedPreferences, getShouldDisableView, getSummary, getTitle, getView, getWidgetLayoutResource, hasKey, hasSpecifiedLayout, isEnabled, isPersistent, isSelectable, notifyChanged, notifyDependencyChange, notifyHierarchyChanged, onAttachedToActivity, onAttachedToHierarchy, onCreateView, onDependencyChanged, onPrepareForRemoval, performClick, persistBoolean, persistFloat, persistInt, persistLong, persistString, requireKey, restoreHierarchyState, saveHierarchyState, setDefaultValue, setDependency, setEnabled, setIntent, setKey, setLayoutResource, setOnPreferenceChangeInternalListener, setOnPreferenceChangeListener, setOnPreferenceClickListener, setOrder, setPersistent, setSelectable, setShouldDisableView, setSummary, setSummary, setTitle, setTitle, setWidgetLayoutResource, shouldCommit, shouldPersist, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CheckBoxPreference

public CheckBoxPreference(Context context,
                          AttributeSet attrs,
                          int defStyle)

CheckBoxPreference

public CheckBoxPreference(Context context,
                          AttributeSet attrs)

CheckBoxPreference

public CheckBoxPreference(Context context)
Method Detail

onBindView

protected void onBindView(View view)
Description copied from class: Preference
Binds the created View to the data for the preference.

This is a good place to grab references to custom Views in the layout and set properties on them.

Make sure to call through to the superclass's implementation.

Overrides:
onBindView in class Preference
Parameters:
view - The View that shows this preference.
See Also:
Preference.onCreateView(ViewGroup)

onClick

protected void onClick()
Description copied from class: Preference
Processes a click on the preference. This includes saving the value to the SharedPreferences. However, the overridden method should call Preference.callChangeListener(Object) to make sure the client wants to update the preference's state with the new value.

Overrides:
onClick in class Preference

setChecked

public void setChecked(boolean checked)
Sets the checked state and saves it to the SharedPreferences.

Parameters:
checked - The checked state.

isChecked

public boolean isChecked()
Returns the checked state.

Returns:
The checked state.

shouldDisableDependents

public boolean shouldDisableDependents()
Description copied from class: Preference
Should return whether this preference's dependents should currently be disabled.

Overrides:
shouldDisableDependents in class Preference
Returns:
True if the dependents should be disabled, otherwise false.

setSummaryOn

public void setSummaryOn(CharSequence summary)
Sets the summary to be shown when checked.

Parameters:
summary - The summary to be shown when checked.

setSummaryOn

public void setSummaryOn(int summaryResId)
Parameters:
summaryResId - The summary as a resource.
See Also:
setSummaryOn(CharSequence)

getSummaryOn

public CharSequence getSummaryOn()
Returns the summary to be shown when checked.

Returns:
The summary.

setSummaryOff

public void setSummaryOff(CharSequence summary)
Sets the summary to be shown when unchecked.

Parameters:
summary - The summary to be shown when unchecked.

setSummaryOff

public void setSummaryOff(int summaryResId)
Parameters:
summaryResId - The summary as a resource.
See Also:
setSummaryOff(CharSequence)

getSummaryOff

public CharSequence getSummaryOff()
Returns the summary to be shown when unchecked.

Returns:
The summary.

getDisableDependentsState

public boolean getDisableDependentsState()
Returns whether dependents are disabled when this preference is on (true) or when this preference is off (false).

Returns:
Whether dependents are disabled when this preference is on (true) or when this preference is off (false).

setDisableDependentsState

public void setDisableDependentsState(boolean disableDependentsState)
Sets whether dependents are disabled when this preference is on (true) or when this preference is off (false).

Parameters:
disableDependentsState - The preference state that should disable dependents.

onGetDefaultValue

protected Object onGetDefaultValue(TypedArray a,
                                   int index)
Description copied from class: Preference
Called when Preference is being inflated and the default value attribute needs to be read. Since different preference types have different value types, the subclass should get and return the default value which will be its value type.

For example, if the value type is String, the body of the method would proxy to TypedArray.getString(int).

Overrides:
onGetDefaultValue in class Preference
Parameters:
a - The set of attributes.
index - The index of the default value attribute.
Returns:
The default value of this preference type.

onSetInitialValue

protected void onSetInitialValue(boolean restoreValue,
                                 Object defaultValue)
Description copied from class: Preference
Implement this to set the initial value of the Preference. If the restoreValue flag is true, you should restore the value from the shared preferences. If false, you should set (and possibly store to shared preferences if Preference.shouldPersist()) to defaultValue.

This may not always be called. One example is if it should not persist but there is no default value given.

Overrides:
onSetInitialValue in class Preference
Parameters:
restoreValue - Whether to restore the persisted value (true), or use the given default value (false).
defaultValue - The default value. Only use if restoreValue is false.

onSaveInstanceState

protected Parcelable onSaveInstanceState()
Description copied from class: Preference
Hook allowing a preference to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can be reconstructed later.

Overrides:
onSaveInstanceState in class Preference
Returns:
Returns a Parcelable object containing the preference's current dynamic state, or null if there is nothing interesting to save. The default implementation returns null.
See Also:
Preference.onRestoreInstanceState(android.os.Parcelable), Preference.saveHierarchyState(android.os.Bundle), Preference.dispatchSaveInstanceState(android.os.Bundle)

onRestoreInstanceState

protected void onRestoreInstanceState(Parcelable state)
Description copied from class: Preference
Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by Preference.onSaveInstanceState(). This function will never be called with a null icicle.

Overrides:
onRestoreInstanceState in class Preference
Parameters:
state - The frozen state that had previously been returned by Preference.onSaveInstanceState().
See Also:
Preference.onSaveInstanceState(), Preference.restoreHierarchyState(android.os.Bundle), Preference.dispatchRestoreInstanceState(android.os.Bundle)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature