ToggleButton控件
来源:互联网 发布:java的发展和前景如何 编辑:程序博客网 时间:2024/06/02 01:52
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.togglebutton.MainActivity" > <ToggleButton android:checked="false" android:textOn="开" android:textOff="关" android:id="@+id/toggleButton1" android:layout_width="match_parent" android:layout_height="wrap_content" /> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/toggleButton1" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_below="@+id/toggleButton1" android:background="@drawable/xiaochuang" /> </RelativeLayout>
package com.example.togglebutton;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.view.View.OnClickListener;import android.widget.CompoundButton;import android.widget.CompoundButton.OnCheckedChangeListener;import android.widget.ImageView;import android.widget.ToggleButton;public class MainActivity extends Activity implements OnCheckedChangeListener{private ToggleButton tb;private ImageView img; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tb=(ToggleButton) findViewById(R.id.toggleButton1); img=(ImageView) findViewById(R.id.imageView1); tb.setOnCheckedChangeListener(this); }@Overridepublic void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {// TODO Auto-generated method stubimg.setBackgroundResource(isChecked?R.drawable.ic_launcher:R.drawable.xiaochuang);}}
0 0
- ToggleButton控件
- ToggleButton控件
- ToggleButton控件
- ToggleButton控件
- ToggleButton控件
- ToggleButton控件
- ToggleButton控件的使用
- Android开关控件ToggleButton
- android控件之ToggleButton
- ToggleButton控件的学习
- ToggleButton控件的学习
- Android--ToggleButton控件
- 控件系列:ToggleButton
- Android控件---ToggleButton
- Android控件之ToggleButton
- 自定义ToggleButton选择控件
- Android控件之ToggleButton
- 控件记录之toggleButton
- mysql的MERGE存储引擎
- ReentrantLock解析,lock与unlock方法分析
- Java学习之构造方法
- 括号配对问题
- 虚拟机无法打开内核设备:\\Global\\vmx86
- ToggleButton控件
- android 4.2版本的sdcard文件目录分析
- IOS 自定义视图的创建
- Arduino 和 HC-SR04 超声波传感器 测距
- BNUOJ-33687-Beautiful Spacing(二分+DP)
- git服务器的简单搭建
- 纯操作系统在国内已经是没法生存的
- k-近邻算法改进约会网站的配对效果
- 高级I/O函数(writev、senfile、dup、mmap、splice、tee)