Code example for ToggleButton

Methods: setTextsetCheckedsetTextOffsetTextOn

0
		view = (ToggleButton) mInflater.inflate(AmlBuilder.localResources.getInt("aml_input_togglebutton"), null);
		Node label = n.getChildNodes().item(0);
		Node offTextNode = n.getAttributes().getNamedItem("offtext");
		Node onTextNode = n.getAttributes().getNamedItem("ontext");
		Node checkedNode = n.getAttributes().getNamedItem("checked");
		if (offTextNode != null) view.setTextOff(offTextNode.getNodeValue());
		if (onTextNode != null) view.setTextOn(onTextNode.getNodeValue());
		String checked = "";
		if (checkedNode != null) checked = checkedNode.getNodeValue().toLowerCase();
		if (label != null && label.getNodeValue().trim().length() > 0) view.setText(label.getNodeValue());
		else if (offTextNode != null && !checked.equals("yes")) view.setText(offTextNode.getNodeValue());
		else if (onTextNode != null && checked.equals("yes")) view.setText(onTextNode.getNodeValue());
		view.setChecked(checked.equals("yes"));
 		AmlBuilder.applyActionAttribute(view, "tap", n.getAttributes().getNamedItem("tap"));
		Log.d(TAG, "New ToggleButton input construction complete from XML node " + n.toString());
	} 
 
	/** 
	 * Get the View created from this object 
	 * @return View to be inserted into parent layout 
	 */