横向开关(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. localStorage注册页面A注册数据在本地储存并在B页面打开

    如题目的这么一个问题, A页面代码 <!DOCTYPE html> <html lang="en"> <head> <meta chars ...

  2. swagger注释API详细说明

    API详细说明 注释汇总 @RequestMapping此注解的推荐配置 value method produces 示例: @ApiOperation("信息软删除") @Api ...

  3. (转)jieba中文分词的.NET版本:jieba.NET

    简介 平时经常用Python写些小程序.在做文本分析相关的事情时免不了进行中文分词,于是就遇到了用Python实现的结巴中文分词.jieba使用起来非常简单,同时分词的结果也令人印象深刻,有兴趣的可以 ...

  4. Highcharts图表.net版开源,支持webform 和 mvc3,完全开源

    Highcharts是一个制作图表的纯Javascript类库,主要特性如下: 兼容性:兼容当今所有的浏览器,包括iPhone.IE和火狐等等: 对个人用户完全免费: 纯JS,无BS: 支持大部分的图 ...

  5. python描述符学习

    目录 一.对象属性的访问控制 二.描述符基本理解 三.基本使用 四.使用描述符完成property.classmethod.staticmethod自定义实现 1.property的自定义实现 2.c ...

  6. 001-Servlet模板

    package ${enclosing_package}; import java.io.IOException; import javax.servlet.ServletException; imp ...

  7. JavaScript引擎理解

    JavaScript 虽然给人感觉是一个多线程执行的语言,但是其实JavaScript引擎是伪多线程,是单线程执行的, 浏览器内核:实现允许多个线程异步执行,这些线程在内核制控下相互配合以保持同步.假 ...

  8. python egg for centos 制作

    经常接触Python的同学可能会注意到,当需要安装第三方python包时,可能会用到easy_install命令.easy_install是由PEAK(Python Enterprise Applic ...

  9. springboot-1-介绍

    之前跟着一个博主学过springboot, 但不怎么全面, 最近看了本书, 汪云飞的springboot 实战, 发现springboot太强大了, 跟着书重新走一遍... 边写边记录 http:// ...

  10. [心平气和读经典]The TCP/IP Guide(003)

    The TCP/IP Guide [Page 43, 44] Scope of The TCP/IP Guide | 本书的讨论范围 The first step to dealing with a ...