横向开关(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)的更多相关文章

  1. Android学习笔记-开关按钮ToggleButton和开关Switch

    本节给大家介绍的Android基本UI控件是:开关按钮ToggleButton和开关Switch,这两个其实都是开关组件,只是后者需要在Android 4.0以后才能使用 所以AndroidManif ...

  2. vue.js开发之开关(switch)组件

    最近开发组件的时候,自定义开发了开关(switch)组件,现将代码整理如下,方便日后复用. toggle-switch.vue <template> <label role=&quo ...

  3. 状态开关按钮(ToggleButton)和开关(Switch)

    ToggleButton支持的XML属性及相关方法1.android:checked----->setChecked(boolean) ----->设置该按钮是否被选中2.android: ...

  4. layui开关switch显示不全问题

    先看效果: 开关显示不全,高度也不对称. 解决: 在所用到的html/jsp中自己加css .layui-form-switch { width: 52px; height: 23px; } 再看效果 ...

  5. ToggleButton与Switch

    状态开关按钮togglebutton和开关switch 状态开关按钮togglebutton和开关switch是由button派生出来的,本质也是按钮,支持BUtton的各种属性,从功能上看,Togg ...

  6. 25.Flutter中的表单 Radio RadioListTile Switch SwitchListTile 以及表单组件实现一个简单的学员登记系统(下)

    四.Radio.RadioListTile单选按钮组件 Radio常用属性: value单选的值. onChanged改变时触发. activeColor:选中的颜色.背景颜色 groupValue: ...

  7. cadence Virtuoso ADE原理图AnalogLib库中的switch使用

    Symbol: switch A,B:等效于一个电阻; C,D:等效于控制开关(CD间的控制电压控制AB的断开或闭合); open switch resistance:开关断开状态下的等效电阻(AB之 ...

  8. Go语言程序设计(1)--基本语法

    第一个程序 package main import "fmt" func main() { fmt.Printf("Hello world") } 通过阅读这个 ...

  9. iOS-UI-UI控件概述

    以下列举一些在开发中可能用得上的UI控件: IBAction和IBOutlet,UIView 1 @interface ViewController : UIViewController 2 3 @p ...

随机推荐

  1. 06-图2 Saving James Bond - Easy Version (25 分)

    This time let us consider the situation in the movie "Live and Let Die" in which James Bon ...

  2. 厉害了,七牛云 CEO 来讲架构了!

    说起许式伟,你应该不陌生,他是七牛云的CEO,ECUG 社区发起人,国内 Go 语言圈的领军人物,曾就职于金山.盛大,有超过 10 年的搜索和分布式存储相关技术的研发经验. 他的个人经历颇为传奇,大学 ...

  3. Hangfire JobStorage.Current property value has not been initialized

    app.UseHangfireServer() 放到 app.UseAbp() 前面 作者: zhaok 出处: http://dotnetmonkey.cnblogs.com/

  4. nodejs(四) --- cluster模块详解

    什么是cluster模块,为什么需要cluster模块?  cluster在英文中有集.群的意思. nodejs默认是单进程的,但是对于多核的cpu来说, 单进程显然没有充分利用cpu,所以,node ...

  5. redux设计到源码 --- 美团点评技术团队(转)

    https://tech.meituan.com/redux-design-code.html

  6. 【文档】三、Mysql Binlog事件类文件和类型

    在内部,服务器使用C++类文件来表示binlog事件.标准在log_event.h文件中,这些类的方法代码在log_event.cc中. log_event是基础类.其他的详细的事件子类都是来源于他. ...

  7. Json&XML比较

    1.定义 1.1 XML定义 扩展标记语言 (Extensible Markup Language, XML) ,用于标记电子文件使其具有结构性的标记语言,可以用来标记数据.定义数据类型,是一种允许用 ...

  8. Oracle 创建表空间和用户

    创建用户: 建立表空间和用户的步骤: 用户 建立:create user 用户名 identified by "密码"; 授权:grant create session to 用户 ...

  9. FocusBI:《DW/BI项目管理》之SSIS执行情况

    微信公众号:FocusBI关注可了解更多的商业智能.数据仓库.数据库开发.爬虫知识及沪深股市数据推送.问题或建议,请关注公众号发送消息留言;如果你觉得FocusBI对你有帮助,欢迎转发朋友圈或在文章末 ...

  10. git基本操作若干

    开发合并分支,推送到远程1. git diff 查看修改内容: . git add -A 添加所有修改: . git commit -am "给人的提示"; 提交修改内容 . gi ...