android jni示例
Today we will learn about Android Toggle Button and Switch in android app. We’ll discuss and implement Switch button Widget and the ToggleButton
widget in our application.
今天,我们将学习android应用中的Android切换按钮和开关。 我们将讨论并实现切换按钮控件和ToggleButton
在我们的应用程序部件。
Android切换按钮 ()
Android Toggle Button is used to display on and off state on a button. Switch is another type of toggle button that’s predominantly used since Android 4.0. Android Switch provides a slider control. Both ToggleButton and Switch are subclasses of CompoundButton
class.
Android切换按钮用于显示按钮的打开和关闭状态。 开关是开关按钮的另一种类型是由于Android 4.0中主要使用。 Android Switch提供了滑块控件。 ToggleButton和Switch都是CompoundButton
类的子类。
XML Attributes used to define a ToggleButton are described below.
下面介绍用于定义ToggleButton的XML属性。
android:disabledAlpha
: The alpha to apply to the indicator when disabledandroid:disabledAlpha
:禁用时应用于指标的Alphaandroid:textOff
: The text for the button when it is not checkedandroid:textOff
:未选中按钮时的文本android:textOn
: The text for the button when it is checkedandroid:textOn
:按钮被选中时的文本
To modify the ToggleButton programmatically the following methods are used.
要以编程方式修改ToggleButton,请使用以下方法。
CharSequence getTextOff()
: It returns the text when button is not in the checked stateCharSequence getTextOff()
:当按钮未处于选中状态时,它返回文本CharSequence getTextOn()
: It returns the text for when button is in the checked stateCharSequence getTextOn()
:返回按钮处于选中状态时的文本void setChecked(boolean checked)
: It changes the checked state of this buttonvoid setChecked(boolean checked)
:更改此按钮的检查状态
Android开关 (Android Switch)
Android Switch or