Switch控件详解
来源:互联网 发布:装修门户网站模板源码 编辑:程序博客网 时间:2024/05/16 08:20
Switch控件详解
原生效果
5.x
4.x
布局
<Switch android:id="@+id/setting_switch" android:layout_width="wrap_content" android:layout_height="wrap_content" />
属性
状态监听
Switch mSwitch = (android.widget.Switch) findViewById(R.id.setting_switch);mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked) { //选中时 do some thing Toast.makeText(MainActivity.this, "enabled", Toast.LENGTH_SHORT).show(); } else { //非选中时 do some thing Toast.makeText(MainActivity.this, "disabled", Toast.LENGTH_SHORT).show(); } }});
设置开关状态显示的文字
<Switch android:id="@+id/setting_switch" android:layout_width="wrap_content" android:layout_height="wrap_content" android:showText="true" android:textOff="关" android:textOn="开" />
设置最小显示宽度
android:switchMinWidth="50dp"
2 0
- Switch控件详解
- Switch控件
- switch详解
- Android Switch控件介绍
- Android Switch控件介绍
- Android自定义Switch控件
- switch控件分析
- Android控件之Switch
- 一个Switch控件
- android 自定义控件 Switch
- Android入门----Switch控件
- 自定义switch控件
- 仿IOS Switch控件
- 自定义Android Switch控件
- switch控件的使用
- 自定义Switch控件二
- Switch开关控件.
- Android UI Switch控件
- easyui treegrid 封装(不用分页,用加载更多按钮)延迟加载加加载更多
- HTTP Response Status Code -- HTTP响应代码中文详解
- PAT-Sharing (25)
- 百练城堡问题
- Mysql 优化
- Switch控件详解
- Tomcat安装、配置、优化及负载均衡详解
- Boost-asio之二
- java网络编程工具-URLConnection
- 设计模式_Builder模式
- redisson2.2.2 使用redis命令 ZREVRANGE 排序
- HDU 1.1.3 A+B for Input-Output Practice (III)
- c Primer Plus(九) -2
- sizeThatFits and sizeToFit是UIView的两个方法