横向开关(switch)
横向开关(switch)
一:属性

1.Activity
//横向开关
public class SwitchActivity extends Activity { private Switch switchComponent; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.switch_layout); switchComponent = (Switch)findViewById(R.id.switchId); switchComponent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
Toast.makeText(SwitchActivity.this, "无线网络打开了!", Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(SwitchActivity.this, "无线网络关闭了!", Toast.LENGTH_SHORT).show();
}
}
});
}
}
2.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<!-- 横向开关 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="5dp" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="无线网:"
android:textSize="20sp" /> <Switch
android:id="@+id/switchId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOn="打开"
android:textOff="关闭"
/> </LinearLayout>
3.效果图如下:

横向开关(switch)的更多相关文章
- Android学习笔记-开关按钮ToggleButton和开关Switch
本节给大家介绍的Android基本UI控件是:开关按钮ToggleButton和开关Switch,这两个其实都是开关组件,只是后者需要在Android 4.0以后才能使用 所以AndroidManif ...
- vue.js开发之开关(switch)组件
最近开发组件的时候,自定义开发了开关(switch)组件,现将代码整理如下,方便日后复用. toggle-switch.vue <template> <label role=&quo ...
- 状态开关按钮(ToggleButton)和开关(Switch)
ToggleButton支持的XML属性及相关方法1.android:checked----->setChecked(boolean) ----->设置该按钮是否被选中2.android: ...
- layui开关switch显示不全问题
先看效果: 开关显示不全,高度也不对称. 解决: 在所用到的html/jsp中自己加css .layui-form-switch { width: 52px; height: 23px; } 再看效果 ...
- ToggleButton与Switch
状态开关按钮togglebutton和开关switch 状态开关按钮togglebutton和开关switch是由button派生出来的,本质也是按钮,支持BUtton的各种属性,从功能上看,Togg ...
- 25.Flutter中的表单 Radio RadioListTile Switch SwitchListTile 以及表单组件实现一个简单的学员登记系统(下)
四.Radio.RadioListTile单选按钮组件 Radio常用属性: value单选的值. onChanged改变时触发. activeColor:选中的颜色.背景颜色 groupValue: ...
- cadence Virtuoso ADE原理图AnalogLib库中的switch使用
Symbol: switch A,B:等效于一个电阻; C,D:等效于控制开关(CD间的控制电压控制AB的断开或闭合); open switch resistance:开关断开状态下的等效电阻(AB之 ...
- Go语言程序设计(1)--基本语法
第一个程序 package main import "fmt" func main() { fmt.Printf("Hello world") } 通过阅读这个 ...
- iOS-UI-UI控件概述
以下列举一些在开发中可能用得上的UI控件: IBAction和IBOutlet,UIView 1 @interface ViewController : UIViewController 2 3 @p ...
随机推荐
- Ubuntu16.04安装视觉SLAM环境(DBow3)
1.从Github上现在DBow3词袋模型库 git clone https://github.com/rmsalinas/DBow3.git 2.开始安装DBow3库,进入DBow3目录 mkdir ...
- springcloud(八)-Hystrix熔断器
雪崩效应 在微服务架构中通常会有多个服务层调用,基础服务的故障可能会导致级联故障,进而造成整个系统不可用的情况,这种现象被称为服务雪崩效应.服务雪崩效应是一种因“服务提供者”的不可用导致“服务消费者” ...
- Manjaro解决 Node.JS Error: ENOSPC
https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details ...
- [中英对照]How PCI Works | PCI工作原理
How PCI Works | PCI工作原理 Your computer's components work together through a bus. Learn about the PCI ...
- 使用gdb进行写操作
使用gdb调试程序,读写操作是很普遍的事情.其中,读操作包括: 读取某个变量的值 读取某个内存地址里的内容 读取某个寄存器的值 对应地,写操作包括: 修改某个变量的值 修改某个内存地址里的内容 修改某 ...
- 图解ARP协议(五)免费ARP:地址冲突了肿么办?
一.免费ARP概述 网络世界纷繁复杂,除了各种黑客攻击行为对网络能造成实际破坏之外,还有一类安全问题或泛安全问题,看上去问题不大,但其实仍然可以造成极大的杀伤力.今天跟大家探讨的,也是技术原理比较简单 ...
- 如何处理服务器SSL收到了一个弱临时Diffie-Hellman 密钥?
当我们用火狐浏览器打开某个HTTPS网站时可能会失败,并且出现如下错误提示: 安全连接失败连接某个URL网址时发生错误. 在服务器密钥交换握手信息中 SSL 收到了一个弱临时 Diff ...
- Ubuntu 安装 Caffe
Caffe Caffe 安装(Python2 CPU版本) 参考博文https://blog.csdn.net/pangyunsheng/article/details/79418896 安装环境 U ...
- html之内容解析
首先我们知道了HTML和css用途,那么今天就来看看HTML的一部分功能和用途. 简单的说HTML就是灵活使用标签,标签就相当于一个网页的骨架,有了这个骨架才能使网页更能区域色彩化. 首先来说HTML ...
- .NET中的集合-ArrayList1
集合命名空间: using.System.Collections;(非泛型集合) using.System.Collections.Genneric(泛型集合) 常用的集合 1.“类似数组”集合:Ar ...