更改切换按钮的Andr​​oid的开/关文 [英] Change the On/Off text of a toggle button Android

查看:156
本文介绍了更改切换按钮的Andr​​oid的开/关文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是<一href="http://stackoverflow.com/questions/7657471/how-to-change-the-background-color-of-the-toggle-button-in-android">changed一个切换按钮 的背景下,现在我期待改变,来了与它的ON / OFF文本。什么是做到这一点的最简单的方法是什么?

I just changed the background of a ToggleButton, and now I'm looking to change the ON/OFF text that comes up with it. What is the easiest way to do this?

推荐答案

您可以使用下面的设置从code中的文本:

You can use the following to set the text from the code:

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设置文本,使用以下命令:

To set the text using xml, use the following:

android:textOff="The text for the button when it is not checked."
android:textOn="The text for the button when it is checked." 

此信息是从这里

This information is from here

这篇关于更改切换按钮的Andr​​oid的开/关文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆