Code example for CheckBox

Methods: setOnCheckedChangeListener

	protected void addBooleanPreference(final BookCataloguePreferences prefs, final int cbId, int viewId, final String key, final boolean defaultValue) {
		// Setup the checkbox 
			CheckBox v = (CheckBox)this.findViewById(cbId); 
			v.setChecked(prefs.getBoolean(key, defaultValue)); 
			v.setOnCheckedChangeListener(new OnCheckedChangeListener() { 
				public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 
					prefs.setBoolean(key, isChecked); 
		// Allow clicking of entire row. 
			View v = this.findViewById(viewId); 
			// Make line flash when clicked. 
			v.setOnClickListener(new OnClickListener() { 
				public void onClick(View v) {
					CheckBox cb = (CheckBox)v.findViewById(cbId);