我只是changed the background of a ToggleButton
,现在我正在寻找更改与它一起出现的开/关文本。做这件事最简单的方法是什么?
发布于 2011-12-30 05:01:04
您可以使用以下内容设置代码中的文本:
toggleButton.setText(textOff);
// Sets the text for when the button is first created.
toggleButton.setTextOff(textOff);
// Sets the text for when the button is not in the checked state.
toggleButton.setTextOn(textOn);
// Sets the text for when the button is in the checked state.
要使用xml设置文本,请使用以下命令:
android:textOff="The text for the button when it is not checked."
android:textOn="The text for the button when it is checked."
此信息来自here
发布于 2011-12-30 05:02:07
在您链接到的示例中,他们使用android:textOn
和android:textOff
将其更改为白天/夜晚
发布于 2014-12-20 17:18:26
将XML设置为:
<ToggleButton
android:id="@+id/flashlightButton"
style="@style/Button"
android:layout_above="@+id/buttonStrobeLight"
android:layout_marginBottom="20dp"
android:onClick="onToggleClicked"
android:text="ToggleButton"
android:textOn="Light ON"
android:textOff="Light OFF" />
https://stackoverflow.com/questions/8673347
复制相似问题