http://developer.android.com/reference/android/preference/CheckBoxPreference.html It also inherits a lot of methods from Preference: http://developer.android.com/reference/android/preference/Preference.html. You can pass the constructor an attribute set where you specify summaryOn and summaryOff and the title
The link you posted is the source code of android. You don't need to implement that in your application as it's already in the android environment