sty*_*972 76 android togglebutton
我只是改变了a的背景ToggleButton
,现在我正在寻找改变它出现的ON/OFF文本.最简单的方法是什么?
rfs*_*010 190
您可以使用以下命令设置代码中的文本:
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.
Run Code Online (Sandbox Code Playgroud)
要使用xml设置文本,请使用以下命令:
android:textOff="The text for the button when it is not checked."
android:textOn="The text for the button when it is checked."
Run Code Online (Sandbox Code Playgroud)
此信息来自此处
将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" />
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
95674 次 |
最近记录: |