Android 使用checkbox 做出switch开关效果和功能
来源:互联网 发布:淘宝中介发论文可靠吗 编辑:程序博客网 时间:2024/05/14 22:22
做到上面的功能,使用switch开关 自定义起来感觉麻烦,就使用checkbox自定义了一个,简单实用,点击上面任何位置都可以进行打开和关闭
xml中代码
<CheckBox android:id="@+id/checkbox_warning" android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableRight="@drawable/checkbox_switch_selector" android:button="@null" android:text="报警" android:layout_marginRight="90dp" android:layout_marginLeft="70dp" android:layout_marginTop="30dp" android:textColor="@color/black" android:textSize="35dp" android:focusable="false" />
checkbox_switch_selector.xml
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_checked="true" android:drawable="@drawable/switch_on"/> <item android:drawable="@drawable/switch_off"/></selector>
java文件中代码
private CheckBox warningSwitch; warningSwitch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if(warningSwitch.isChecked()){ .... }else{ .... } } });
0 0
- Android 使用checkbox 做出switch开关效果和功能
- Ajax应用:使用jQuery和PHP实现功能开关效果
- css使用checkbox来打造switch开关按钮
- unity3d 使用Instantiate功能做出子彈發射效果
- Android 开关控件Switch的简单使用
- Android中的ToggleButton和Switch开关控件
- Android学习路之开关按钮ToggleButton和开关Switch
- ToggleButton(开关按钮)和Switch(开关)的使用
- android学习总结(16.08.29)单选按钮(RadioButton),多选按钮(CheckBox)和开关按钮(Switch)
- android开关按钮,Switch,ToggleButton,RadioButton,CheckBox ,多种实现开关按钮
- Android 自定义简单的滑动效果switch开关
- jQuery和PHP打造功能开关效果
- Android自定义Switch开关
- Android Switch开关
- Android Switch开关
- 状态开关按钮ToggleButton和开关switch的功能和用法
- 状态开关按钮ToggleButton和开关switch的功能和用法
- 第13章:状态开关按钮(ToggleButton)和开关(Switch)的功能和用法
- 111. Minimum Depth of Binary Tree*
- Caffe、TensorFlow、MXnet三个开源库对比
- HttpServletRequest对象
- Base64 笔记
- 输入一个数组,最大的元素与第一个元素交换,最小的元素与最后一个元素交换
- Android 使用checkbox 做出switch开关效果和功能
- gpl
- usaco The Perfect Stall(二分匹配模板)
- 几何水题 acdream 1414 Geometry Problem
- 站点收集
- Android经典项目开发之天气APP实例分享
- STM32串口学习总结(经典)
- 罗永浩当年求职新东方"一万多字的求职信"
- jQuery中级--$(function() {})和$(document).ready(function(){ })