ToggleButton setTextOn - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ToggleButton setTextOn method.

This code example shows how to use the following methods:setOnCheckedChangeListener, setText, setWidth, setTextOff, setTextOn
		this.mLayout = new RelativeLayout(mContext);
		LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
				LayoutParams.FILL_PARENT);
		params.setMargins(0, 3, 0, 0);
		this.mLayout.setLayoutParams(params);
		this.mButton = new ToggleButton(mContext);
		this.mButton.setText("Torch");
		this.mButton.setTextOn("Torch");
		this.mButton.setTextOff("Torch");
		this.mButton.setWidth(LayoutParams.FILL_PARENT);
		this.mButton
				.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
 
					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						if (isChecked) {
							ledOn(); 
						} else { 
							ledOff(); 
						} 
6
CodeRank
This code example shows how to use the following methods:setText, setChecked, setTextOff, setTextOn
		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 
6
CodeRank
This code example shows how to use the following methods:setChecked, setTextOff, setTextOn
This code example shows how to use the following methods:setOnCheckedChangeListener, setText, setTextOff, setTextOn
This code example shows how to use the following methods:setOnCheckedChangeListener, setChecked, setTextOff, setTextOn
		super.onCreate(savedInstanceState);
		 
		FrameLayout content = new FrameLayout(this);
		renderSurfaceView = new RenderSurfaceView(this);
		 
		toggle = new ToggleButton(this);
		toggle.setTextOn("Set Alpha");
        toggle.setTextOff("Set Rotate");
        toggle.setChecked(false);
		toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				 
			@Override 
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				mode = isChecked;
			} 
		}); 
		 
		// 500x500でViewを作成 
        content.addView(renderSurfaceView, new FrameLayout.LayoutParams(500, 500, Gravity.CENTER));
        content.addView(toggle, new FrameLayout.LayoutParams(200,200, Gravity.TOP));
6
CodeRank
This code example shows how to use the following methods:getTextOn, setTextOff, setTextOn
		super(realm, button);
		this.button = button;
	} 
 
	public void doSetValue(final Object value) {
		String oldValue = button.getTextOn().toString();
		String newValue = value == null ? "" : value.toString(); //$NON-NLS-1$
		button.setTextOn(newValue);
		button.setTextOff(newValue);
 
		if (!newValue.equals(oldValue)) {
			fireValueChange(Diffs.createValueDiff(oldValue, newValue));
		} 
	} 
 
	public Object doGetValue() {
		return button.getTextOn();
	} 
 
	public Object getValueType() {
5
CodeRank
This code example shows how to use the following methods:setText, setTextOff, setTextOn
            container.addView(linearLayout, i);
        } 
    } 
 
    private void clearButtonText(ToggleButton button) {
        button.setText("");
        button.setTextOff("");
        button.setTextOn("");
    } 
 
    public boolean[] saveGrid() { 
        boolean[] toggleState = new boolean[TOTAL_BUTTONS];
 
        for (int i = 0; i < TOTAL_BUTTONS; i++) {
            toggleState[i] = buttonContainer.get(i).isChecked();
        } 
        return toggleState;
    } 
 
    public void restoreGrid(boolean[] toggleState) {
5
CodeRank
This code example shows how to use the following methods:getTextOn, setTextOn
		super(realm, button);
		this.button = button;
	} 
 
	public void doSetValue(final Object value) {
		String oldValue = button.getTextOn().toString();
		String newValue = value == null ? "" : value.toString(); //$NON-NLS-1$
		button.setTextOn(newValue);
 
		if (!newValue.equals(oldValue)) {
			fireValueChange(Diffs.createValueDiff(oldValue, newValue));
		} 
	} 
 
	public Object doGetValue() {
		return button.getTextOn();
	} 
 
	public Object getValueType() {
		return String.class;
5
CodeRank
This code example shows how to use the following methods:setTextOn
	public CharSequence getButtonText() {
		return mToggleButton.getText();
	} 
	 
	public void setButtonTextOn(CharSequence text) {
		mToggleButton.setTextOn(text);
	} 
	 
	public CharSequence getButtonTextOn() {
		return mToggleButton.getTextOn();
	} 
	 
	public void setButtonTextOff(CharSequence text) {
		mToggleButton.setTextOff(text);
	} 
	 
	public CharSequence getButtonTextOff() {
		return mToggleButton.getTextOff();
	} 
	 
4
CodeRank

Related ToggleButton setTextOn Questions & Answers:

setTextOn Method Overview
Sets the text for when the button is in the checked state.
See Code Examples for other Android ToggleButton Methods: