横向开关(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 ...
随机推荐
- AI简单平移追踪算法
1.比较坐标追踪法 追踪者会不停地比较自身和目标的x坐标和y坐标,每x和y上一个单位的移动为一个周期,该算法虽然简单好用,但实用性差且不智能化,如果追踪者数量增加,路线会显得单调,由于都是先走个对角线 ...
- 第十篇---javascript函数this关键字
<script type="text/javascript" charset="utf-8"> //this:this对象是指运行时期基于执行环境所 ...
- 用Akka构建一个简易的分布式文件系统
本来初期打算用Hadoop 2,可是后来有限的服务器部署了Solr Cloud,各种站点,发现资源不够了,近10T的文件,已经几乎把服务器的磁盘全部用光.想来想去,由于目前架构基于Scala的,所以还 ...
- 对Tensorflow中tensor的理解
Tensor即张量,在tensorflow中所有的数据都通过张量流来传输,在看代码的时候,对张量的概念很不解,很容易和矩阵弄混,今天晚上查了点资料,并深入了解了一下,简单总结一下什么是张量的阶,以及张 ...
- *2.2.3 加入objection机制
在上一节中,虽然输出了“main_phase is called”,但是“data is drived”并没有输出.而main_phase是一个完整的任务,没有理由只执行第一句,而后面的代码不执行.看 ...
- Compiler Principle
1.Einleitung 1.1 Der Überblick über Compiler 1.1.1 Lexikalische Analyse Die lexikalische Analyse zer ...
- 单独烧录kernel
使用fastboot: adb reboot bootloader //adb 进入BootLoader(fastboot是BootLoader的命令) fastboot flash boot boo ...
- Golang之并发资源竞争(读写锁)
前面的有篇文章在讲资源竞争的时候,提到了互斥锁.互斥锁的根本就是当一个goroutine访问的时候,其他goroutine都不能访问,这样肯定保证了资源的同步,避免了竞争,不过也降低了性能. 仔细剖析 ...
- [转]The NTLM Authentication Protocol and Security Support Provider
本文转自:http://davenport.sourceforge.net/ntlm.html#ntlmHttpAuthentication The NTLM Authentication Proto ...
- [转]Redis 数据类型
本文转自:http://www.runoob.com/redis/redis-data-types.html Redis支持五种数据类型:string(字符串),hash(哈希),list(列表),s ...