Skip to content

Most visited

Recently visited

navigation

CheckBoxPreference

public class CheckBoxPreference
extends TwoStatePreference

java.lang.Object
   ↳ android.preference.Preference
     ↳ android.preference.TwoStatePreference
       ↳ android.preference.CheckBoxPreference


A Preference that provides checkbox widget functionality.

This preference will store a boolean into the SharedPreferences.

Summary

XML attributes

android:disableDependentsState The state (true for on, or false for off) that causes dependents to be disabled. 
android:summaryOff The summary for the Preference in a PreferenceActivity screen when the CheckBoxPreference is unchecked. 
android:summaryOn The summary for the Preference in a PreferenceActivity screen when the CheckBoxPreference is checked. 

Inherited XML attributes

From class android.preference.Preference

Inherited constants

From class android.preference.Preference

Public constructors

CheckBoxPreference(Context context, AttributeSet attrs, int defStyleAttr)
CheckBoxPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
CheckBoxPreference(Context context, AttributeSet attrs)
CheckBoxPreference(Context context)

Protected methods

void onBindView(View view)

Binds the created View to the data for this Preference.

Inherited methods

From class android.preference.TwoStatePreference
From class android.preference.Preference
From class java.lang.Object
From interface java.lang.Comparable

XML attributes

android:disableDependentsState

The state (true for on, or false for off) that causes dependents to be disabled. By default, dependents will be disabled when this is unchecked, so the value of this preference is false.

May be a boolean value, such as "true" or "false".

android:summaryOff

The summary for the Preference in a PreferenceActivity screen when the CheckBoxPreference is unchecked. If separate on/off summaries are not needed, the summary attribute can be used instead.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:summaryOn

The summary for the Preference in a PreferenceActivity screen when the CheckBoxPreference is checked. If separate on/off summaries are not needed, the summary attribute can be used instead.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

Public constructors

CheckBoxPreference

added in API level 1
CheckBoxPreference (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

CheckBoxPreference

added in API level 21
CheckBoxPreference (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

CheckBoxPreference

added in API level 1
CheckBoxPreference (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

CheckBoxPreference

added in API level 1
CheckBoxPreference (Context context)

Parameters
context Context

Protected methods

onBindView

added in API level 1
void onBindView (View view)

Binds the created View to the data for this 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.

Parameters
view View: The View that shows this Preference.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)