ToggleButton

两种状态

·状态button

    -继承自CompoundButton

·主要属性:-Android:textOn

   -Android:textOff

·主要方法:

  -isChecked()

·主要事件

-setOnClickListener(OnClickListener l)

xml中:

增加一个ToggleButton控件

 <ToggleButton
android:id="@+id/btnTest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tv_info"
android:layout_below="@+id/textView1"
android:layout_marginTop="39dp"
android:checked="true"
android:onClick="doClick"
android:textOff="关闭"
android:textOn="打开" />

MainActivity中对控件进行监听:

public void doClick(View v){
if(btnTest.isChecked()){
tv.setText("button被选中");
}else{
tv.setText("button未被选中");
}
}

ToggleButton控件的更多相关文章

  1. 自定义控件(模仿微信ToggleButton控件)

    弄过android开发的都知道,系统有一个默认的ToggleButton,但很多人都觉得他很难看,当然也包括我.如果你感觉他不难看,那你就继续使用系统的吧,这篇文章对你来说是多余的了. 今天来写一个模 ...

  2. ToggleButton控件,Switch控件

    (一) 1.效果图    2. activity_main.xml <?xml version="1.0" encoding="utf-8"?> & ...

  3. 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButton, AppBarButton, AppBarToggleButton

    [源码下载] 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButt ...

  4. 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButton, AppBarButton, AppBarToggleButton

    介绍背水一战 Windows 10 之 控件(按钮类) ButtonBase Button HyperlinkButton RepeatButton ToggleButton AppBarButton ...

  5. ToggleButton开关状态按钮控件

    ToggleButton开关状态按钮控件 一.简介 1. 2.ToggleButton类结构 父类是CompoundButton,引包的时候注意下 二.ToggleButton开关状态按钮控件使用方法 ...

  6. Android自定义控件1--自定义控件介绍

    Android控件基本介绍 Android本身提供了很多控件比如我们常用的有文本控件TextView和EditText:按钮控件Button和ImageButton状态开关按钮ToggleButton ...

  7. Button控件

    1.通过设置AutoSize(bool)属性来控制按钮的大小以适应文本的长度 btn_One.AutoSize = true;//设置按钮基于内容自动调整大小 2.当按钮得到焦点是自动放大,失去焦点时 ...

  8. Pro Android 4 第六章 构建用户界面以及使用控件(一)

         目前为止,我们已经介绍了android的基础内容,但是还没开始接触用户界面(UI).本章我们将开始探讨用户界面和控件.我们先讨论一下android中UI设计的一般原理,然后我们在介绍一下an ...

  9. 在 UWP 中实现 Expander 控件

    WPF 中的 Expander 控件在 Windows 10 SDK 中并不提供,本文主要说明,如何在 UWP 中创建这样一个控件.其效果如下图: 首先,分析该控件需要的一些特性,它应该至少包括如下三 ...

随机推荐

  1. Linux常用PDF阅读软件

    1.福昕阅读器是一款PDF文档阅读器,对中文的支持度非常高.福昕阅读器作为全球最流行的PDF阅读器,能够快速打开.浏览.审阅.注释.签署及打印任何PDF文件. 2.evince是一个支持多种格式的文件 ...

  2. CentOS7的聚合链路

    1.环境介绍 [root@rhcc ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) ENERAL.DEVICE: en ...

  3. R与并行计算

    本文在Creative Commons许可证下发布 什么是并行计算? 并行计算,准确地说应该包括高性能计算机和并行软件两个方面.不过,近年来随着个人PC机,廉价机群,以及各种加速卡(NVIDIA GP ...

  4. Webhook

    Webhook就是用户通过自定义回调函数的方式来改变Web应用的一种行为,这些回调函数可以由不是该Web应用官方的第三方用户或者开发人员来维护,修改.通过Webhook,你可以自定义一些行为通知到指定 ...

  5. 洛谷——P2446 [SDOI2010]大陆争霸

    https://www.luogu.org/problem/show?pid=2446#sub 题目背景 在一个遥远的世界里有两个国家:位于大陆西端的杰森国和位于大陆东端的克里斯国.两个国家的人民分别 ...

  6. cogs 26. 分组

    26. 分组 ★   输入文件:dataa.in   输出文件:dataa.out   简单对比时间限制:1 s   内存限制:128 MB[问题描述] 现有 n 个学生, 要分成X1 ,X2 ,.. ...

  7. [React] Validate Custom React Component Props with PropTypes

    In this lesson we'll learn about how you can use the prop-types module to validate a custom React co ...

  8. OpenCASCADE Job - 武汉中南

    中南设计集团(武汉)工程技术研究院有限公司是中南工程咨询设计集团有限公司(以下简称“中南设计集团”)打造的工程技术研发和科研创新平台,为中南设计集团旗下全资子公司,于2018年2月成立.公司业务范围涵 ...

  9. Http post提交和get提交

    public string  PostParameter(string url)         {  string message="";             GetOrde ...

  10. mysql异常Lock wait timeout exceeded; try restarting transaction

    mysql中使用update语句更新数据报错: Lock wait timeout exceeded; try restarting transaction. 这是由于你要更新的表的锁在其它线程手里. ...