Code example for ToggleButton

Methods: getId, isChecked

0
 
	@Override 
	public void addView(View child, int index, ViewGroup.LayoutParams params) {
		if (child instanceof ToggleButton) {
			final ToggleButton button = (ToggleButton) child;
			if (button.isChecked()) {
				mProtectFromCheckedChange = true;
				if (mCheckedId != -1) {
					setCheckedStateForView(mCheckedId, false);
				} 
				mProtectFromCheckedChange = false;
				setCheckedId(button.getId());
			} 
		} 
 
		super.addView(child, index, params);
	} 
 
	/** 
	 * <p> 
	 * Sets the selection to the radio button whose identifier is passed in