Java Code Examples for android.widget.CompoundButton#setText()

The following examples show how to use android.widget.CompoundButton#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChoiceGroup.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
@Override
public void set(int elementNum, String stringPart, Image imagePart) {
	synchronized (selected) {
		strings.set(elementNum, stringPart);
		images.set(elementNum, imagePart);

		if (buttongroup != null) {
			CompoundButton button = buttons.get(elementNum);

			button.setText(stringPart);

			if (imagePart != null) {
				button.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(imagePart.getBitmap()), null, null, null);
			} else {
				button.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
			}

			button.setCompoundDrawablePadding(button.getPaddingLeft());
		} else if (adapter != null) {
			adapter.set(elementNum, stringPart, imagePart);
		}
	}
}
 
Example 2
Source File: ChoiceGroup.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
private void addButton(CompoundButton button, int index, String stringPart, Image imagePart, boolean checked) {
	button.setText(stringPart);

	if (imagePart != null) {
		button.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(imagePart.getBitmap()), null, null, null);
	}

	button.setCompoundDrawablePadding(button.getPaddingLeft());

	button.setId(index);
	button.setChecked(checked);
	button.setOnCheckedChangeListener(checklistener);

	if (index == buttons.size()) {
		buttons.add(button);
	} else {
		buttons.add(index++, button);

		if (buttons.get(index).getId() != index) {
			updateButtonIDs(index);
		}
	}

	buttongroup.addView(button);
}
 
Example 3
Source File: BooleanSettingsObject.java    From EasySettings with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param compoundButton changes the text of the given {@link CompoundButton}
 *                       according if it's "on" or "off"
 */
public void setTextAccordingToState(CompoundButton compoundButton)
{
	if(compoundButton.isChecked())
	{
		compoundButton.setText(onText);
	}

	else if(compoundButton.isChecked() == false)
	{
		compoundButton.setText(offText);
	}
}