Code example for CheckBox

Methods: setChecked, setId, setLayoutParams, setOnCheckedChangeListener

0
				RelativeLayout.LayoutParams.WRAP_CONTENT,
				RelativeLayout.LayoutParams.WRAP_CONTENT);
		checkboxparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
		checkboxparams.addRule(RelativeLayout.CENTER_VERTICAL);
 
		checkbox = new CheckBox(getContext());
		checkbox.setLayoutParams(checkboxparams);
		checkbox.setOnCheckedChangeListener(this);
		checkbox.setId(CHECKBOX_ID);
		 
		 
 
		layout.addView(title);
		layout.addView(description);
		layout.addView(checkbox);
		layout.setId(android.R.id.widget_frame);
 
		checkService(); 
		 
		return layout;
		 
		 
	} 
 
	 
	 
	@Override 
	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		if (isChecked) {
			turnOnService(); 
		} else { 
			turnOffService(); 
		} 
	} 
	 
	private void checkService() { 
		boolean ison = TuioServiceTools.isServiceRunning(getContext());
		checkbox.setChecked(ison);
		 
	} 
	 
	private void turnOnService() { 
    	Intent service = new Intent("com.sigmusic.tacchi.tuio.TUIO_SERVICE");