android.widget.CompoundButton#setText ( )源码实例Demo

下面列出了android.widget.CompoundButton#setText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: J2ME-Loader   文件: ChoiceGroup.java
@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);
		}
	}
}
 
源代码2 项目: J2ME-Loader   文件: ChoiceGroup.java
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);
}
 
源代码3 项目: EasySettings   文件: BooleanSettingsObject.java
/**
 *
 * @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);
	}
}