android jni示例_Android切换按钮,开关示例

本文介绍了Android应用中 ToggleButton 和 Switch 的使用,包括它们的XML属性、编程修改方法及在项目中的示例。Android Switch作为Checkbox和RadioButton的优秀替代品,具有简洁的实现和较少的资源需求。
摘要由CSDN通过智能技术生成

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)

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属性。

  1. android:disabledAlpha: The alpha to apply to the indicator when disabled

    android:disabledAlpha :禁用时应用于指标的Alpha
  2. android:textOff: The text for the button when it is not checked

    android:textOff :未选中按钮时的文本
  3. android:textOn: The text for the button when it is checked

    android:textOn :按钮被选中时的文本

To modify the ToggleButton programmatically the following methods are used.

要以编程方式修改ToggleButton,请使用以下方法。

  1. CharSequence getTextOff(): It returns the text when button is not in the checked state

    CharSequence getTextOff() :当按钮未处于选中状态时,它返回文本
  2. CharSequence getTextOn(): It returns the text for when button is in the checked state

    CharSequence getTextOn() :返回按钮处于选中状态时的文本
  3. void setChecked(boolean checked): It changes the checked state of this button

    void setChecked(boolean checked) :更改此按钮的检查状态

Android开关 (Android Switch)

Android Switch or

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值