gpt4 book ai didi

android - 更改切换按钮 Android 的开/关文本

转载 作者:IT老高 更新时间:2023-10-28 13:11:31 25 4
gpt4 key购买 nike

我只是 changed the background of a ToggleButton ,现在我正在寻找更改随之而来的 ON/OFF 文本。最简单的方法是什么?

最佳答案

您可以使用以下内容从代码中设置文本:

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

关于android - 更改切换按钮 Android 的开/关文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8673347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com