文档章节

Android开发范例实战宝典

MoreYoungG
 MoreYoungG
发布于 2016/08/04 14:06
字数 50559
阅读 193
收藏 5

 

环境配置
JDK
//下载:个人推荐使用最新的JDK,可以避免很多不必要的麻烦
//环境配置:打开jdk安装目录下的bin,如F:\JDK\jdk1.8.0_101\bin,将这个地址配置到环境变量的path中即可
eclipse
//下载:http://www.eclipse.org/downloads/eclipse-packages/中找到Eclipse for Android Developers 
//安装:解压即可
SDK
//更新:使用国内的SDK镜像,地址:https://dsx.bugly.qq.com/repository/1#Windows
//获得如:域名 : a8521e72c694.repository.bugly.qq.com  端口:80 填入Android SDK Manager中的=>Tools=>Options中。
//SDK下载选择:
//Tools下:Android SDK Tools、Android SDK Platform-tools、Android SDK Build-tools(选择最高版本)
//Android各版本(API XX):由于我们使用Genymotion模拟器,我们不需要下载文件名带Image的文件,Google APIs在国内开发用不上
//Extras:Android Support Repository、Google Use Driver、intel x86 emulator accelerator
Genymotion模拟器插件的安装
//下载插件:
//com.genymobile.genymotion.ide.eclipse.plugin_1.0.3.201403261147.jar
//com.genymobile.genymotion.ide.eclipse.plugin_1.0.3.201403261147.jar
//添加插件
//将2个jar文件放入eclipse下plugins文件夹中,重启eclipse
Genymotion模拟器的安装
//下载:http://www.genymotion.net/ 先注册
//安装:根据提示即可
//运行:将Genymotion目录下的所有可执行文件,兼容性改为server 2008,管理员方式运行
//配置:
//Settings=>VirtualBox:放置个安卓个版本虚拟机的位置
//Settings=>ADB:选择Use custom Android SDK tools,配置Android SDK,选择SDK的路径
VBox
//下载:https://www.virtualbox.org/wiki/Downloads
//安装:根据提示即可
//运行:将VBox目录下的所有可执行文件,兼容性改为server 2008,管理员方式运行
让你的程序变成美女
Android中基本控件的使用 
//更改文字标签的内容 
	<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="I am a Android Developer" />
//更改手机页面的背景色 
	<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"
    android:background="@color/background_dark"
    tools:context="com.example.test.MainActivity" >
	//android:background="@color/background_dark",同时我们在res/value下创建color.xml内容增加<color name="background_dark">#FF0000</color>
//文字超链接 
	<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:autoLink="web"
        android:text="www.baidu.com" />
//让你的文字标签更加丰富多彩 
	private TextView Tv;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Tv = (TextView) findViewById(R.id.TV);
		String str="<font color=\"#FF0000\">我有一个梦想</font><br>"
				+"<font color=\"#00FF00\">成为优秀的</font><br>"
				+"<font color=\"#0000FF\">Android开发者</font><br>"
				+"<font color=\"#0F0FFF\">制作属于自己的</font><br>"
				+"<font color=\"#0F0F0F\">应用</font><br>";
		Tv.setText(Html.fromHtml(str));
	}
	<TextView
        android:id="@+id/TV"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />
//用户名密码输入框 
	<EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入用户名"/>
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:password="true"
        android:hint="请输入密码"/>
	//使用线性布局LinearLayout,加入android:orientation="vertical"属性
//电话号码输入框 
	private EditText EtPhone;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		EtPhone = (EditText) findViewById(R.id.EtPhone);
		EtPhone.addTextChangedListener(new TextWatcher() {
			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
			}
			@Override
			public void beforeTextChanged(CharSequence s, int start, int count, int after) {
			}
			@Override
			public void afterTextChanged(Editable s) {
				String phoneStr = s.toString();
				boolean b = isPhoneNumber(phoneStr);
				if(b){
					EtPhone.setTextColor(Color.rgb(0, 255, 0));
				}else{
					EtPhone.setTextColor(Color.rgb(255, 0, 0));
				}
			}
		});
	}
	public boolean isPhoneNumber(String str){
		String regex = "^((13[0-9])|(15[^4,\\D])||(18[0,5-9]))\\d{8}$";
		Pattern p = Pattern.compile(regex);
		Matcher m = p.matcher(str);
		return m.find();
	}
	//使用线性布局LinearLayout,加入android:orientation="vertical"属性
//更改输入框的文字字体 
	 <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:typeface="normal"
        android:text="国"
        android:hint="我的字体是normal"/>
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:typeface="sans"
        android:text="国"
        android:hint="我的字体是sans"/>
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:typeface="serif"
        android:text="国"
        android:hint="我的字体是serif"/>
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:typeface="monospace"
        android:text="国"
        android:hint="我的字体是monospace"/>
    <EditText 
        android:id="@+id/Et"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="我的字体是华文行楷"/>
	//使用线性布局LinearLayout,加入android:orientation="vertical"属性
//我同意上述条款的页面 
	private TextView TV;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		TV = (TextView) findViewById(R.id.TV);
		String str="一、使用规则<br>二、文明用户<br>";
		TV.setText(Html.fromHtml(str));
	}
	<TextView 
        android:id="@+id/TV"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
        
	<CheckBox 
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:text="我同意如上条款"/>
	//使用线性布局LinearLayout,加入android:orientation="vertical"属性
//爱好调查页面 
	private CheckBox cbBasketball;
	private CheckBox cbPingpangball;
	private CheckBox cbFootball;
	private TextView TvResult;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		findView();
		setListener();
	}
	private void setListener() {
		cbBasketball.setOnCheckedChangeListener(myChangeListener);
		cbPingpangball.setOnCheckedChangeListener(myChangeListener);
		cbFootball.setOnCheckedChangeListener(myChangeListener);
	}
	OnCheckedChangeListener myChangeListener = new OnCheckedChangeListener() {
		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			setText();
		}
	};
	private void findView(){
		cbBasketball = (CheckBox) findViewById(R.id.CbBasketball);
		cbPingpangball = (CheckBox) findViewById(R.id.CbPingbangball);
		cbFootball = (CheckBox) findViewById(R.id.CbFootball);
		TvResult = (TextView) findViewById(R.id.TvResult);
	}
	private void setText() {
		String str;
		TvResult.setText("");
		if(cbBasketball.isChecked()){
			str = TvResult.getText().toString()+cbBasketball.getText().toString()
					+",";
			TvResult.setText(str);
		}
		if(cbPingpangball.isChecked()){
			str = TvResult.getText().toString()+cbPingpangball.getText().toString()
					+",";
			TvResult.setText(str);
		}
		if(cbFootball.isChecked()){
			str = TvResult.getText().toString()+cbFootball.getText().toString()
					+",";
			TvResult.setText(str);
		}
	}
	<CheckBox 
        android:id="@+id/CbBasketball"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="篮球"/>
    <CheckBox 
        android:id="@+id/CbPingbangball"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="乒乓球"/>
    <CheckBox 
        android:id="@+id/CbFootball"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="足球"/>
    <TextView 
        android:id="@+id/TvResult"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world"/>
	//使用线性布局LinearLayout,加入android:orientation="vertical"属性
//政治面貌调查表 
	<RadioGroup 
        android:id="@+id/RgPolitical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <RadioButton 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="党员"/>
        <RadioButton 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="群众"/>
        <RadioButton 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="团员"/>
    </RadioGroup>
	//使用线性布局LinearLayout,加入android:orientation="vertical"属性
//应用中的关闭声音的按钮 
	 <ToggleButton 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textOn="声音开启"
        android:textOff="声音关闭"/>
    <Switch 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textOn="声音开启"
        android:textOff="声音关闭"/>
//应用中的音量调节效果 
	<SeekBar 
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:max="100"
       android:progress="2"/>
//服务星级评价效果 
	<RatingBar 
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:numStars="5"
       android:stepSize="0.5"/>
//页面加载中效果 
	<ProgressBar 
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"/>
//日期获取框效果 
	private TextView Tv;
	private DatePicker Dp;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		findView();
		setListener();
	}
	private void findView() {
		Tv = (TextView) findViewById(R.id.Tv);
		Dp = (DatePicker) findViewById(R.id.Dp);
	}
	private void setListener() {
		Dp.init(2016, 10, 12, new OnDateChangedListener() {
			@Override
			public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
				Tv.setText("Year"+Dp.getYear()
				+"\nMonth:"+(Dp.getMonth()+1)
				+"\nDay:"+Dp.getDayOfMonth());
			}
		});
	}
	<TextView 
       android:id="@+id/Tv"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:text="请输入您的生日"/>
   <DatePicker 
       android:id="@+id/Dp"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"/>
	 //使用线性布局LinearLayout,加入android:orientation="vertical"属性  
//时间获取框效果 
	<TextView 
       android:id="@+id/Tv"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:text="请输入闹钟时间"/>
   <TimePicker 
       android:id="@+id/Tp"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"/>
	private TextView Tv;
	private TimePicker Tp;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		findView();
		setListener();
	}
	private void findView() {
		Tv = (TextView)findViewById(R.id.Tv);
		Tp = (TimePicker)findViewById(R.id.Tp);
	}
	private void setListener() {
		Tp.setOnTimeChangedListener(new OnTimeChangedListener() {
			@Override
			public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
				Tv.setText("hour:"+hourOfDay+"\nminute:"+minute);
			}
		});
	}
//钟表显示效果 
	<AnalogClock 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <DigitalClock 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
//秒表应用 
	private Button BtnStart;
	private Button BtnStop;
	private Button BtnReset;
	private Chronometer Chron;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		findView();
		setListener();
	}
	private void setListener() {
		BtnStart.setOnClickListener(myListener);
		BtnStop.setOnClickListener(myListener);
		BtnReset.setOnClickListener(myListener);
	}
	OnClickListener myListener = new OnClickListener() {
		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.BtnStart:
				Chron.start();
				break;
			case R.id.BtnStop:
				Chron.stop();
				break;
			case R.id.BtnReset:
				Chron.setBase(SystemClock.elapsedRealtime());;
				break;
			default:
				break;
			}
		}
	};
	private void findView() {
		BtnReset = (Button) findViewById(R.id.BtnReset);
		BtnStart = (Button) findViewById(R.id.BtnStart);
		BtnStop = (Button) findViewById(R.id.BtnStop);
		Chron = (Chronometer) findViewById(R.id.Chron);
	}
	<Chronometer 
        android:id="@+id/Chron"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <Button 
        android:id="@+id/BtnStart"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="开始计时"/>
    <Button 
        android:id="@+id/BtnStop"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="停止计时"/>
    <Button 
        android:id="@+id/BtnReset"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="重置计时器"/>
//圆角按钮效果 
	<?xml version="1.0" encoding="utf-8"?>
	<shape xmlns:android="http://schemas.android.com/apk/res/android" >
		<solid android:color="#00CCFF"/>
		<corners android:radius="10dip"/>
		<padding 
			android:bottom="5dp"
			android:left="5dp"
			android:right="5dp"
			android:top="5dp"/>
	</shape>
	<Button 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/btn_bg"
        android:text="圆角按钮"/>
Android中常见布局的使用 
//用户注册页面的制作 
	<EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入注册用户名"
        android:ems="10"/>
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入密码"
        android:ems="10"
        android:inputType="textPassword"/>
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请再次输入密码"
        android:ems="10"
        android:inputType="textPassword"/>
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入你的邮箱"
        android:ems="10"
        android:inputType="textEmailAddress"/>
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入你的手机号"
        android:ems="10"/>
    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/btn_bg"
        android:text="注册"/>
	//btn_bg.xml
	<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="#00CCFF"/>
    <corners android:radius="10dip"/>
	<padding 
	    android:bottom="5dp"
	    android:left="5dp"
	    android:right="5dp"
	    android:top="5dp"/>
	</shape>
//学生成绩列表页面的制作 
	<TableLayout 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"
		android:orientation="vertical"
		tools:context="com.example.test.MainActivity" >
		
		<TableRow android:orientation="horizontal">
			<TextView 
				android:layout_width="wrap_content"
				android:layout_height="match_parent"
				android:gravity="center"
				android:textSize="20dp"
				android:layout_weight="1"
				android:text="学生姓名"/>
			<TextView 
				android:layout_width="match_parent"
				android:layout_height="match_parent"
				android:layout_weight="1"
				android:textSize="20dp"
				android:gravity="center"
				android:text="数学成绩"/>
			<TextView 
				android:layout_width="match_parent"
				android:layout_height="match_parent"
				android:layout_weight="1"
				android:textSize="20dp"
				android:gravity="center"
				android:text="语文成绩"/>
		</TableRow>
	   <TableRow android:orientation="horizontal">
		   <TextView 
			   android:layout_width="wrap_content"
			   android:layout_height="match_parent"
			   android:layout_weight="1"
			   android:gravity="center"
			   android:text="张三"/>
		   <TextView 
			   android:layout_width="wrap_content"
			   android:layout_height="match_parent"
			   android:layout_weight="1"
			   android:gravity="center"
			   android:text="90"/>
		   <TextView 
			   android:layout_width="wrap_content"
			   android:layout_height="match_parent"
			   android:layout_weight="1"
			   android:gravity="center"
			   android:text="83"/>
	   </TableRow>
	   <TableRow android:orientation="horizontal">
		   <TextView 
			   android:layout_width="match_parent"
			   android:layout_height="match_parent"
			   android:layout_weight="1"
			   android:gravity="center"
			   android:text="李四"/>
		   <TextView 
			   android:layout_width="wrap_content"
			   android:layout_height="match_parent"
			   android:layout_weight="1"
			   android:gravity="center"
			   android:text="83"/>
		   <TextView 
			   android:layout_width="wrap_content"
			   android:layout_height="match_parent"
			   android:layout_weight="1"
			   android:gravity="center"
			   android:text="83"/>
	   </TableRow>
	   <TableRow android:orientation="horizontal">
		   <TextView 
			   android:layout_width="match_parent"
			   android:layout_height="match_parent"
			   android:layout_weight="1"
			   android:gravity="center"
			   android:text="王五"/>
		   <TextView 
			   android:layout_width="wrap_content"
			   android:layout_height="match_parent"
			   android:layout_weight="1"
			   android:gravity="center"
			   android:text="81"/>
		   <TextView 
			   android:layout_width="wrap_content"
			   android:layout_height="match_parent"
			   android:layout_weight="1"
			   android:gravity="center"
			   android:text="82"/>
	   </TableRow>
	</TableLayout>
//登录页面的制作 
	<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.test.MainActivity" >
		<EditText 
			android:id="@+id/EtUsername"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入用户名"/>
		<EditText 
			android:id="@+id/EtPassword"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_below="@id/EtUsername"
			android:hint="请输入密码"/>
		<Button 
			android:id="@+id/BtnExit"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_below="@id/EtPassword"
			android:layout_alignRight="@id/EtPassword"
			android:hint="退出"/>
		<Button 
			android:id="@+id/BtnLogin"
			android:layout_below="@id/EtPassword"
			android:layout_toLeftOf="@id/BtnExit"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:hint="登录"/>
	</RelativeLayout>
//图片相框效果 
	<FrameLayout 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.test.MainActivity" >
		
		<ImageView 
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:src="@drawable/imgbg"/>
		<ImageView 
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:padding="30dp"
			android:src="@drawable/imgbg"/>
	</FrameLayout>
//商城专区效果 
	<GridLayout 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.test.MainActivity" 
		android:columnCount="4">
		
		<TextView 
			android:layout_width="150dp"
			android:layout_height="60dp"
			android:layout_columnSpan="2"
			android:layout_gravity="left"
			android:background="@color/blue"
			android:gravity="center"
			android:text="男装"
			android:width="50dp"/>
		<TextView 
			android:layout_width="150dp"
			android:layout_height="60dp"
			android:layout_columnSpan="2"
			android:background="@color/red"
			android:gravity="center"
			android:text="女装"
			android:width="50dp"/>
		<TextView 
			android:layout_width="75dp"
			android:layout_height="60dp"
			android:layout_gravity="top"
			android:background="@color/red"
			android:gravity="center"
			android:text="童装"
			android:width="25dp"/>
		<TextView 
			android:layout_width="150dp"
			android:layout_height="60dp"
			android:layout_columnSpan="2"
			android:background="@color/green"
			android:gravity="center"
			android:text="流行装"
			android:width="50dp"/>
		<TextView 
			android:layout_width="75dp"
			android:layout_height="60dp"
			android:background="@color/blue"
			android:gravity="center"
			android:text="嘻哈"
			android:width="25dp"/>
	</GridLayout>
//三字经阅读程序 
	<ScrollView 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.test.MainActivity" >
		
		<TextView 
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:text="@string/tv_content"/>
		
	</ScrollView>
//计算器程序的页面设计 
	<LinearLayout 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:orientation="vertical"
		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.test.MainActivity" >

		<EditText
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="0" />

		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal" >

			<Button
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="7" />

			<Button
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="8" />

			<Button
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="9" />

			<Button
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="/" />

			<Button
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="%" />
		</LinearLayout>

		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal" >

			<Button
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="4" />

			<Button
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="5" />

			<Button
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="6" />

			<Button
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="*" />

			<Button
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="1/x" />
		</LinearLayout>

		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal" >

			<LinearLayout
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="4"
				android:orientation="vertical" >

				<LinearLayout
					android:layout_width="match_parent"
					android:layout_height="wrap_content" >

					<Button
						android:layout_width="wrap_content"
						android:layout_height="wrap_content"
						android:layout_weight="1"
						android:text="1" />

					<Button
						android:layout_width="wrap_content"
						android:layout_height="wrap_content"
						android:layout_weight="1"
						android:text="2" />

					<Button
						android:layout_width="wrap_content"
						android:layout_height="wrap_content"
						android:layout_weight="1"
						android:text="3" />

					<Button
						android:layout_width="wrap_content"
						android:layout_height="wrap_content"
						android:layout_weight="1"
						android:text="-" />
				</LinearLayout>

				<LinearLayout
					android:layout_width="match_parent"
					android:layout_height="wrap_content" >

					<Button
						android:layout_width="wrap_content"
						android:layout_height="wrap_content"
						android:layout_weight="2"
						android:text="0" />

					<Button
						android:layout_width="wrap_content"
						android:layout_height="wrap_content"
						android:layout_weight="1"
						android:text="." />

					<Button
						android:layout_width="wrap_content"
						android:layout_height="wrap_content"
						android:layout_weight="1"
						android:text="+" />
				</LinearLayout>
			</LinearLayout>

			<Button
				android:layout_width="wrap_content"
				android:layout_height="match_parent"
				android:layout_weight="1"
				android:text="=" />
		</LinearLayout>

	</LinearLayout>
Android中高级组件的使用 
//单词搜索补全效果 
	<LinearLayout 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:orientation="vertical"
		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.test.MainActivity" >
		<AutoCompleteTextView 
			android:id="@+id/Actv"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"/>
	</LinearLayout>
	private static final String[] words = {"abbreviation","action","active","act",
			"ally","ball","bask"};
	private AutoCompleteTextView Actv;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Actv = (AutoCompleteTextView) findViewById(R.id.Actv);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,words);
		Actv.setAdapter(adapter);
	}
//多匹配补全效果 
	private static final String[] words = {"zhangsan","zhangshi","lisi","liliu",
		"liushasha","wangli","wangzhengsan"};
	private MultiAutoCompleteTextView Mactv;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Mactv = (MultiAutoCompleteTextView) findViewById(R.id.Mactv);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,words);
		Mactv.setAdapter(adapter);
		Mactv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
	}
	<LinearLayout 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:orientation="vertical"
		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.test.MainActivity" >
		<MultiAutoCompleteTextView 
			android:id="@+id/Mactv"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"/>
	</LinearLayout>
//用户使用的操作系统调查表 
	private TextView Tv;
	private Spinner Sp;
	ArrayAdapter<CharSequence> adapter;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		findView();
		setSp();
	}
	private void setSp() {
		adapter = ArrayAdapter.createFromResource(this,R.array.System,
				android.R.layout.simple_spinner_item);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		Sp.setAdapter(adapter);
		Sp.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
				Tv.setText(adapter.getItem(position).toString());
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				Tv.setText("Selected Noting");
			}
		});
	}
	private void findView() {
		Tv = (TextView) findViewById(R.id.Tv);
		Sp = (Spinner) findViewById(R.id.Sp);
	}
	<LinearLayout 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:orientation="vertical"
		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.test.MainActivity" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"/>
		<Spinner 
			android:id="@+id/Sp"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"/>
	</LinearLayout>
	<resources>
		<string-array name="System">
			<item>Windows</item>
			<item>Linux</item>
			<item>Unix</item>
			<item>Google Cloud</item>
			<item>Other</item>
		</string-array>    
	</resources>
//电影票预售表格效果 
	private GridView Gv;
	ArrayAdapter<CharSequence> adapter;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		findView();
		setGv();
	}
	private void setGv() {
		adapter = ArrayAdapter.createFromResource(this, R.array.seat, android.R.layout.simple_gallery_item);
		Gv.setAdapter(adapter);
	}
	private void findView() {
		Gv = (GridView) findViewById(R.id.Gv);
	}
	<string-array name="seat">
	    <item>A1 满</item>
	    <item>A2 满</item>
	    <item>A3 满</item>
	    <item>B1 满</item>
	    <item>B2 空</item>
	    <item>B3 满</item>
	    <item>C1 满</item>
	    <item>C2 空</item>
	    <item>C3 满</item>
	</string-array>  
	<LinearLayout 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:orientation="vertical"
		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.test.MainActivity" >
		<GridView 
			android:id="@+id/Gv"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:numColumns="3"></GridView>
	</LinearLayout>
//文件表格列表效果 
	<?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="vertical">
		<ImageView 
			android:id="@+id/Iv"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			/>
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content" 
			android:gravity="center"
			/>
	</LinearLayout>
	<LinearLayout 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"
		android:orientation="vertical">
		<GridView
			android:id="@+id/Gv"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:numColumns="3" />

	</LinearLayout>
	public class MyFile {
		public String FileName;
		public int ImgId;
		public MyFile() {
			super();
		}
		public MyFile(String fileName, int imgId) {
			super();
			FileName = fileName;
			ImgId = imgId;
		}	
	}
	public class MainActivity extends Activity {
		private GridView Gv;
		FileListAdapter adapter;
		private List<MyFile> fileList = new ArrayList<MyFile>();
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState); 
			setContentView(R.layout.activity_main);
			findView();
			setData();
			setGv();
		}
		private void setData() {
			fileList.add(new MyFile("test.txt",R.drawable.doc));
			fileList.add(new MyFile("test.jpg",R.drawable.img));
			fileList.add(new MyFile("test.avi",R.drawable.video));
			fileList.add(new MyFile("dir1",R.drawable.dir));
			fileList.add(new MyFile("test.doc",R.drawable.doc));
			fileList.add(new MyFile("test.rmvb",R.drawable.video));
			fileList.add(new MyFile("test.mp4",R.drawable.video));
			fileList.add(new MyFile("test.rm",R.drawable.video));
			fileList.add(new MyFile("test.png",R.drawable.img));
			fileList.add(new MyFile("dir2",R.drawable.dir));
		}
		private void setGv() {
			adapter = new FileListAdapter(this,fileList);
			Gv.setAdapter(adapter);
		}
		private void findView() {
			Gv = (GridView) findViewById(R.id.Gv);
		}
	}
	public class FileListAdapter extends BaseAdapter {
		private Context mContext;
		private List<MyFile> fileList;
		public FileListAdapter(Context c,List<MyFile> fl) {
			mContext = c;
			fileList = fl;
		}
		@Override
		public int getCount() {
			return fileList.size();
		}
		@Override
		public Object getItem(int position) {
			return fileList.get(position);
		}
		@Override
		public long getItemId(int position) {
			return position;
		}
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			ViewHolder viewholder =new ViewHolder();
			if (convertView == null) {
				convertView = LayoutInflater.from(mContext).inflate(
						R.layout.activity_filelist_item, null);
			}
			viewholder.fileImage = (ImageView) convertView
					.findViewById(R.id.Iv);
			viewholder.fileName = (TextView) convertView
					.findViewById(R.id.Tv);
			viewholder.fileImage.setBackgroundResource(fileList.get(position).ImgId);
			viewholder.fileName.setText(fileList.get(position).FileName);
			return convertView;
		}
		class ViewHolder {
			ImageView fileImage;
			TextView fileName;
		}
	}
//学生名单表 
	<LinearLayout 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"
		android:orientation="vertical">
		<ListView
			android:id="@+id/Lv"
			android:layout_width="match_parent"
			android:layout_height="match_parent"/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private ListView Lv;
		ArrayAdapter<CharSequence> adapter;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState); // 调用父类的onCreate方法
			setContentView(R.layout.activity_main);
			findView();
			setGv();
		}
		private void setGv() {
			adapter = ArrayAdapter.createFromResource(
					this, R.array.names, android.R.layout.simple_gallery_item);
			Lv.setAdapter(adapter);
		}
		private void findView() {
			Lv = (ListView) findViewById(R.id.Lv);
		}
	}
	<resources>
		<string-array name="names">
			<item>张三</item>
			<item>李四</item>
			<item>王五</item>
			<item>赵六</item>
			<item>田七</item>
			<item>刘一</item>
			<item>孙二</item>
			<item>周九</item>
			<item>郑十</item>
		</string-array>
	</resources>
//手机联系人列表效果 
	<LinearLayout 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"
		android:orientation="vertical">
		<ListView
			android:id="@+id/Lv"
			android:layout_width="match_parent"
			android:layout_height="match_parent"/>
	</LinearLayout>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
		android:layout_width="match_parent"
		android:layout_height="match_parent"
		android:orientation="horizontal" >
		<ImageView
			android:id="@+id/IvNews"
			android:layout_width="wrap_content"
			android:layout_height="match_parent" />
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:orientation="vertical" >
			<TextView
				android:id="@+id/TvNewsTitle"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:gravity="left"
				android:textSize="20sp" />
			<TextView
				android:id="@+id/TvNewsInfo"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:gravity="left"
				android:textSize="10sp" />
		</LinearLayout>
	</LinearLayout>
	public class MainActivity extends Activity {
		private ListView Lv;
		private PeopleListAdapter adapter;
		private Cursor cursor;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState); // 调用父类的onCreate方法
			setContentView(R.layout.activity_main);
			findView();
			setData();
			setLv();
		}
		private void setData() {
			cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
		}
		private void setLv() {
			adapter = new PeopleListAdapter(this,cursor);
			Lv.setAdapter(adapter);
		}
		private void findView() {
			Lv = (ListView) findViewById(R.id.Lv);
		}
	}
	public class People {
		public String PeopleName;		
		public int ImgId;				
		public String PeopleNumber;		
		public People() {
			super();
		}
		public People(String fileName, int imgId, String info) {
			super();
			PeopleName = fileName;
			ImgId = imgId;
			PeopleNumber = info;
		}
	}
	public class PeopleListAdapter extends CursorAdapter {
		private LayoutInflater mInflater;
		public PeopleListAdapter(Context c, Cursor cursor) {
			super(c, cursor);
			mInflater = LayoutInflater.from(c);
		}
		@Override
		public void bindView(View view, Context context, Cursor cursor) {
			ViewHolder viewholder = new ViewHolder();
			viewholder.PeopleImage = (ImageView) view.findViewById(R.id.IvNews);
			viewholder.PeopleName = (TextView) view.findViewById(R.id.TvNewsTitle);
			viewholder.PeopleNumber = (TextView) view.findViewById(R.id.TvNewsInfo);
			viewholder.PeopleImage.setBackgroundResource(R.drawable.ic_launcher);
			viewholder.PeopleName
					.setText(cursor.getString(cursor
							.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)));
			viewholder.PeopleNumber
					.setText(cursor.getString(cursor
							.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
		}
		@Override
		public View newView(Context context, Cursor cursor, ViewGroup parent) {
			return mInflater
					.inflate(R.layout.activity_list_item, parent, false);
		}
		class ViewHolder {
			ImageView PeopleImage;
			TextView PeopleName;
			TextView PeopleNumber;
		}
	}
//画廊图片浏览器 
	<LinearLayout 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"
		android:orientation="vertical">
		<Gallery
			android:id="@+id/Gal"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content" />
		<ImageView 
			android:id="@+id/Iv"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private Gallery Gal;
		private ImageView Iv;
		private ImgsAdapter adapter;
		private Integer[] imgsIds = { 
				R.drawable.b1, 
				R.drawable.b2,
				R.drawable.b3, 
				R.drawable.b4, 
				R.drawable.b5, 
				R.drawable.b6 };
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState); 
			setContentView(R.layout.activity_main);
			findView();
			setGal();
		}
		private void setGal() {
			adapter = new ImgsAdapter(this,imgsIds);
			Gal.setAdapter(adapter);
			Gal.setOnItemClickListener(myOnitemListener);
		}
		OnItemClickListener myOnitemListener = new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Iv.setImageResource(imgsIds[arg2]);
			}
		};
		private void findView() {
			Gal = (Gallery) findViewById(R.id.Gal);
			Iv = (ImageView) findViewById(R.id.Iv);
		}
	}
	public class ImgsAdapter extends BaseAdapter{
		private Context context;
		private Integer[] imgsArray;
		public ImgsAdapter(Context context,Integer[] mImageIds){
			this.context = context;
			imgsArray = mImageIds;
		}
		@Override
		public int getCount() {
			return imgsArray.length;
		}
		@Override
		public Object getItem(int arg0) {
			return arg0;
		}
		@Override
		public long getItemId(int arg0) {
			return arg0;
		}
		@Override
		public View getView(int arg0, View arg1, ViewGroup arg2) {
			if (arg1 == null) {
				ImageView view = new ImageView(this.context);
				int id = imgsArray[arg0];
				view.setImageResource(id);
				view.setLayoutParams(new Gallery.LayoutParams(80,80));
				view.setScaleType(ImageView.ScaleType.FIT_XY);
				arg1 = view;
			}
			return arg1;
		}
	}
//仿iPhone的CoverFlow效果 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
		android:layout_width="fill_parent"
		android:layout_height="fill_parent" >
		<com.wyl.example.MyCoverFlow
			android:id="@+id/Mcf"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"/>
	</LinearLayout>
	public class MyCoverFlow extends Gallery {
		private Camera camera = new Camera();
		private int maxRotation = 60;
		private int zoom = -120;
		private int center;
		public MyCoverFlow(Context context) {
			super(context);
			this.setStaticTransformationsEnabled(true);
		}
		public MyCoverFlow(Context context, AttributeSet attrs) {
			super(context, attrs);
			this.setStaticTransformationsEnabled(true);
		}
		public MyCoverFlow(Context context, AttributeSet attrs, int defStyle) {
			super(context, attrs, defStyle);
			this.setStaticTransformationsEnabled(true);
		}
		private int getCenter() {
			return (getWidth() - getPaddingLeft() - getPaddingRight()) / 2
					+ getPaddingLeft();
		}
		private int getCenterOfView(View view) {
			return view.getLeft() + view.getWidth() / 2;
		}
		protected boolean getChildStaticTransformation(View child, Transformation trans) {
			final int childCenter = getCenterOfView(child);
			final int childWidth = child.getWidth();
			int rotationAngle = 0;
			trans.clear();
			trans.setTransformationType(Transformation.TYPE_MATRIX);
			if (childCenter == center) {
				setTransImage((ImageView) child, trans, 0);
			} else {
				rotationAngle = (int) (((float) (center - childCenter) / childWidth) * maxRotation);
				if (Math.abs(rotationAngle) > maxRotation) {
					rotationAngle = (rotationAngle < 0) ? -maxRotation
							: maxRotation;
				}
				setTransImage((ImageView) child, trans, rotationAngle);
			}
			return true;
		}
		protected void onSizeChanged(int w, int h, int oldw, int oldh) {
			center = getCenter();
			super.onSizeChanged(w, h, oldw, oldh);
		}
		private void setTransImage(ImageView child, Transformation t,
				int rotationAngle) {
			camera.save();
			final Matrix imageMatrix = t.getMatrix();
			final int imageHeight = child.getLayoutParams().height;
			final int imageWidth = child.getLayoutParams().width;
			final int rotation = Math.abs(rotationAngle);
			camera.translate(0.0f, 0.0f, 100.0f);
			if (rotation < maxRotation) {
				float zoomAmount = (float) (zoom + (rotation * 1.5));
				camera.translate(0.0f, 0.0f, zoomAmount);
			}
			camera.rotateY(rotationAngle);
			camera.getMatrix(imageMatrix);
			imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2));
			imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2));
			camera.restore();
		}
	}
	public class MainActivity extends Activity {
		private Integer[] imgs = { R.drawable.b1,
				R.drawable.b2, R.drawable.b3,
				R.drawable.b4, R.drawable.b5,
				R.drawable.b6 };
		private MyCoverFlow CoverFlow;
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			setCoverFlow();
		}
		private void setCoverFlow() {
			ImgsAdapter adapter = new ImgsAdapter(this, imgs);
			adapter.invertedImages();
			CoverFlow = (MyCoverFlow) findViewById(R.id.Mcf);
			CoverFlow.setAdapter(adapter);
		}
	}
	public class ImgsAdapter extends BaseAdapter {
		private Context context;
		private Integer[] ImagIds;
		private ImageView[] Images;
		public ImgsAdapter(Context c, Integer[] ImageIds) {
			context = c;
			ImagIds = ImageIds;
			Images = new ImageView[ImagIds.length];
		}
		public boolean invertedImages() {
			final int reflectionGap = 4;
			int index = 0;
			for (int imageId : ImagIds) {
				Bitmap originalImage = BitmapFactory.decodeResource(context
						.getResources(), imageId);
				int width = originalImage.getWidth();
				int height = originalImage.getHeight();
				Matrix matrix = new Matrix();
				matrix.preScale(1, -1);
				Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0,
						height / 2, width, height / 2, matrix, false);
				Bitmap bitmapWithReflection = Bitmap.createBitmap(width,
						(height + height / 2), Config.ARGB_8888);
				Canvas canvas = new Canvas(bitmapWithReflection);
				canvas.drawBitmap(originalImage, 0, 0, null);
				Paint deafaultPaint = new Paint();
				canvas.drawRect(0, height, width, height + reflectionGap,
						deafaultPaint);
				canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);
				Paint paint = new Paint();
				LinearGradient shader = new LinearGradient(0, originalImage
						.getHeight(), 0, bitmapWithReflection.getHeight()
						+ reflectionGap, 0x70ffffff, 0x00ffffff, TileMode.CLAMP);
				paint.setShader(shader);
				paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
				canvas.drawRect(0, height, width, bitmapWithReflection.getHeight()
						+ reflectionGap, paint);
				ImageView imageView = new ImageView(context);
				imageView.setImageBitmap(bitmapWithReflection);
				imageView.setLayoutParams(new Gallery.LayoutParams(100, 200));
				Images[index++] = imageView;
			}
			return true;
		}
		public int getCount() {
			return ImagIds.length;
		}
		public Object getItem(int position) {
			return position;
		}
		public long getItemId(int position) {
			return position;
		}
		public View getView(int position, View convertView, ViewGroup parent) {
			return Images[position];
		}
	}
//菜单弹出效果 
	<LinearLayout 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"
		android:orientation="vertical">
		<TextView 
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:text="请按键盘物理菜单键,弹出选项菜单"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private final static int Menu_1 = Menu.FIRST;
		private final static int Menu_2 = Menu.FIRST + 1;
		private final static int Menu_3 = Menu.FIRST + 2;
		private final static int Menu_4 = Menu.FIRST + 3;
		private final static int Menu_5 = Menu.FIRST + 4;
		private final static int Menu_6 = Menu.FIRST + 5;
		private final static int Menu_7 = Menu.FIRST + 6;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState); // 调用父类的onCreate方法
			setContentView(R.layout.activity_main);
		}
		public boolean onCreateOptionsMenu(Menu m) {
			m.add(0, Menu_1, 0, "编辑模式"); 
			m.add(0, Menu_2, 0, "修改壁纸");
			m.add(0, Menu_3, 0, "全局搜索");
			m.add(0, Menu_4, 0, "桌面缩略图");
			m.add(0, Menu_5, 0, "桌面效果");
			m.add(0, Menu_6, 0, "系统设置");
			m.add(0, Menu_7, 0, "用户信息");
			return super.onCreateOptionsMenu(m);
		}
		public boolean onOptionsItemSelected(MenuItem item) {
			switch (item.getItemId()) {
			case 1:
				Toast.makeText(this, "你点击了编辑模式选项", Toast.LENGTH_SHORT).show();
				break;
			case 2:
				Toast.makeText(this, "你点击了修改壁纸", Toast.LENGTH_SHORT).show();
				break;
			case 3:
				Toast.makeText(this, "你点击了全局搜索", Toast.LENGTH_SHORT).show();
				break;
			case 4:
				Toast.makeText(this, "你点击了桌面缩略图", Toast.LENGTH_SHORT).show();
				break;
			case 5:
				Toast.makeText(this, "你点击了桌面效果", Toast.LENGTH_SHORT).show();
				break;
			case 6:
				Toast.makeText(this, "你点击了系统设置", Toast.LENGTH_SHORT).show();
				break;
			case 7:
				Toast.makeText(this, "你点击了用户信息", Toast.LENGTH_SHORT).show();
				break;
			}
			return super.onOptionsItemSelected(item);
		}
		public void onOptionsMenuClosed(Menu menu) {
			Log.e("onOptionsMenuClosed","用户菜单关闭了");
		}
		public boolean onPrepareOptionsMenu(Menu menu) {
			Log.e("onPrepareOptionsMenu","用户菜单准备好被显示了");
			return true;
		}
	}
//打开文件的子菜单效果 
	<LinearLayout 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"
		android:orientation="vertical">
		<TextView 
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:text="请点击物理菜单键显示菜单,再次点击菜单选项显示子菜单"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		final int Menu_1 = Menu.FIRST;
		final int Menu_2 = Menu.FIRST + 1;
		final int Menu_3 = Menu.FIRST + 2;
		final int Menu_4 = Menu.FIRST + 3;
		final int Menu_5 = Menu.FIRST + 4;
		final int Menu_6 = Menu.FIRST + 5;
		final int Menu_7 = Menu.FIRST + 6;
		final int Menu_8 = Menu.FIRST + 7;
		final int Menu_9 = Menu.FIRST + 8;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState); // 调用父类的onCreate方法
			setContentView(R.layout.activity_main);
		}
		public boolean onCreateOptionsMenu(Menu m) {
			SubMenu fileMenu = m.addSubMenu("新建");
			fileMenu.add(0, Menu_1, 0, "文件1"); 
			fileMenu.add(0, Menu_2, 0, "文件2");
			fileMenu.add(0, Menu_3, 0, "文件3");
			SubMenu openMenu = m.addSubMenu("打开");
			openMenu.add(0, Menu_4, 0, "文件4"); 
			openMenu.add(0, Menu_5, 0, "文件5");
			openMenu.add(0, Menu_6, 0, "文件6");
			SubMenu saveMenu = m.addSubMenu("保存");
			saveMenu.add(0, Menu_7, 0, "文件7"); 
			saveMenu.add(0, Menu_8, 0, "文件8");
			saveMenu.add(0, Menu_9, 0, "文件9");
			return super.onCreateOptionsMenu(m);
		}
		public boolean onOptionsItemSelected(MenuItem item) {
			switch (item.getItemId()) {
			case 1:
				Toast.makeText(this, "新建文件1", Toast.LENGTH_SHORT).show();
				break;
			case 2:
				Toast.makeText(this, "新建文件2", Toast.LENGTH_SHORT).show();
				break;
			case 3:
				Toast.makeText(this, "新建文件3", Toast.LENGTH_SHORT).show();
				break;
			case 4:
				Toast.makeText(this, "打开文件4", Toast.LENGTH_SHORT).show();
				break;
			case 5:
				Toast.makeText(this, "打开文件5", Toast.LENGTH_SHORT).show();
				break;
			case 6:
				Toast.makeText(this, "打开文件6", Toast.LENGTH_SHORT).show();
				break;
			case 7:
				Toast.makeText(this, "保存文件7", Toast.LENGTH_SHORT).show();
				break;
			case 8:
				Toast.makeText(this, "保存文件8", Toast.LENGTH_SHORT).show();
				break;
			case 9:
				Toast.makeText(this, "保存文件9", Toast.LENGTH_SHORT).show();
				break;
			}
			return super.onOptionsItemSelected(item);
		}
	}
//文本框的复制粘贴全选菜单 
	<LinearLayout 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"
		android:orientation="vertical">
		<TextView 
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:text="请点击物理菜单键显示菜单,再次点击菜单选项显示子菜单"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		final int Menu_1 = Menu.FIRST;
		final int Menu_2 = Menu.FIRST + 1;
		final int Menu_3 = Menu.FIRST + 2;
		final int Menu_4 = Menu.FIRST + 3;
		final int Menu_5 = Menu.FIRST + 4;
		final int Menu_6 = Menu.FIRST + 5;
		final int Menu_7 = Menu.FIRST + 6;
		final int Menu_8 = Menu.FIRST + 7;
		final int Menu_9 = Menu.FIRST + 8;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState); // 调用父类的onCreate方法
			setContentView(R.layout.activity_main);
		}
		public boolean onCreateOptionsMenu(Menu m) {
			SubMenu fileMenu = m.addSubMenu("新建");
			fileMenu.add(0, Menu_1, 0, "文件1"); 
			fileMenu.add(0, Menu_2, 0, "文件2");
			fileMenu.add(0, Menu_3, 0, "文件3");
			SubMenu openMenu = m.addSubMenu("打开");
			openMenu.add(0, Menu_4, 0, "文件4"); 
			openMenu.add(0, Menu_5, 0, "文件5");
			openMenu.add(0, Menu_6, 0, "文件6");
			SubMenu saveMenu = m.addSubMenu("保存");
			saveMenu.add(0, Menu_7, 0, "文件7"); 
			saveMenu.add(0, Menu_8, 0, "文件8");
			saveMenu.add(0, Menu_9, 0, "文件9");
			return super.onCreateOptionsMenu(m);
		}
		public boolean onOptionsItemSelected(MenuItem item) {
			switch (item.getItemId()) {
			case 1:
				Toast.makeText(this, "新建文件1", Toast.LENGTH_SHORT).show();
				break;
			case 2:
				Toast.makeText(this, "新建文件2", Toast.LENGTH_SHORT).show();
				break;
			case 3:
				Toast.makeText(this, "新建文件3", Toast.LENGTH_SHORT).show();
				break;
			case 4:
				Toast.makeText(this, "打开文件4", Toast.LENGTH_SHORT).show();
				break;
			case 5:
				Toast.makeText(this, "打开文件5", Toast.LENGTH_SHORT).show();
				break;
			case 6:
				Toast.makeText(this, "打开文件6", Toast.LENGTH_SHORT).show();
				break;
			case 7:
				Toast.makeText(this, "保存文件7", Toast.LENGTH_SHORT).show();
				break;
			case 8:
				Toast.makeText(this, "保存文件8", Toast.LENGTH_SHORT).show();
				break;
			case 9:
				Toast.makeText(this, "保存文件9", Toast.LENGTH_SHORT).show();
				break;
			}
			return super.onOptionsItemSelected(item);
		}
	}
//仿UC浏览器的伪菜单效果 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<GridView
			android:id="@+id/Gv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:gravity="center"
			android:horizontalSpacing="15dip"
			android:numColumns="3"
			android:stretchMode="columnWidth"
			android:background="@android:color/black"
			android:verticalSpacing="15dip" />
	</LinearLayout>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
		<ImageView
			android:id="@+id/Iv"
			android:layout_width="40dip"
			android:layout_height="40dip"
			android:layout_gravity="center"/>
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:gravity="center"
			android:textColor="@android:color/white"
			android:text="选项" />
	</LinearLayout>
	<LinearLayout 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"
	android:orientation="vertical">
		<TextView
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击Menu物理键,弹出自定义菜单"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private AlertDialog Dia;		
		private GridView Gv;			
		private View view;				
		private final int ITEM_1 = 0;	
		private final int ITEM_2 = 1;	
		private final int ITEM_3 = 2;	
		private final int ITEM_4 = 3;	
		private final int ITEM_5 = 4;	
		private final int ITEM_6 = 5;	
		private final int ITEM_7 = 6;	
		private final int ITEM_8 = 7;	
		private final int ITEM_9 = 8;	
		private List<Item> li = new ArrayList<Item>();
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState); 
			setContentView(R.layout.activity_main);
			setData();
			setMenuView();
		}
		private void setData() {
			li.add(new Item(R.drawable.m1, "搜索"));
			li.add(new Item(R.drawable.m2, "文件管理"));
			li.add(new Item(R.drawable.m3, "下载管理"));
			li.add(new Item(R.drawable.m4, "全屏"));
			li.add(new Item(R.drawable.m5, "网址"));
			li.add(new Item(R.drawable.m6, "书签"));
			li.add(new Item(R.drawable.m7, "加入书签"));
			li.add(new Item(R.drawable.m8, "分享"));
			li.add(new Item(R.drawable.m9, "退出"));
		}
		private void setMenuView() {
			view = View.inflate(this, R.layout.menu_layout, null);
			Dia = new AlertDialog.Builder(this).create();
			Dia.setView(view);
			Dia.setOnKeyListener(new OnKeyListener() {
				public boolean onKey(DialogInterface dialog, int keyCode,
						KeyEvent event) {
					if (keyCode == KeyEvent.KEYCODE_MENU)
						dialog.dismiss();
					return false;
				}
			});
			GvAdapter gva = new GvAdapter(this, li);
			Gv = (GridView) view.findViewById(R.id.Gv);
			Gv.setAdapter(gva);
			Gv.setOnItemClickListener(new OnItemClickListener() {
				public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
						long arg3) {
					switch (arg2) {
					case ITEM_1:
						Toast.makeText(MainActivity.this,"您选择了搜索选项",Toast.LENGTH_SHORT).show();
						break;
					case ITEM_2:
						Toast.makeText(MainActivity.this,"您选择了文件管理",Toast.LENGTH_SHORT).show();
						break;
					case ITEM_3:
						Toast.makeText(MainActivity.this,"您选择了下载管理",Toast.LENGTH_SHORT).show();
						break;
					case ITEM_4:
						Toast.makeText(MainActivity.this,"您选择了全屏",Toast.LENGTH_SHORT).show();
						break;
					case ITEM_5:
						Toast.makeText(MainActivity.this,"您选择了网址",Toast.LENGTH_SHORT).show();
						break;
					case ITEM_6:
						Toast.makeText(MainActivity.this,"您选择了书签",Toast.LENGTH_SHORT).show();
						break;
					case ITEM_7:
						Toast.makeText(MainActivity.this,"您选择了加入书签",Toast.LENGTH_SHORT).show();
						break;
					case ITEM_8:
						Toast.makeText(MainActivity.this,"您选择了分享",Toast.LENGTH_SHORT).show();
						break;
					case ITEM_9:
						Toast.makeText(MainActivity.this,"您选择了退出",Toast.LENGTH_SHORT).show();
						break;
					}
					Dia.dismiss();
				}
			});
		}
		@Override
		public boolean onCreateOptionsMenu(Menu menu) {
			menu.add("menu");//必须创建一项
			return super.onCreateOptionsMenu(menu);
		}
		@Override
		public boolean onMenuOpened(int featureId, Menu menu) {
			if (Dia == null) {
				Dia = new AlertDialog.Builder(this).setView(view).show();
			} else {
				Dia.show();
			}
			return false;
		}
	}
	public class Item {
		public int itemImg;			
		public String itemTitle;	
		public Item(int itemImg, String itemTitle) {
			super();
			this.itemImg = itemImg;
			this.itemTitle = itemTitle;
		}
	}
	public class GvAdapter extends BaseAdapter {
		private Context mContext;
		private List<Item> fileList;
		public GvAdapter(Context c,List<Item> fl) {
			mContext = c;
			fileList = fl;
		}
		@Override
		public int getCount() {
			return fileList.size();
		}
		@Override
		public Object getItem(int position) {
			return fileList.get(position);
		}
		@Override
		public long getItemId(int position) {
			return position;
		}
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			ViewHolder viewholder =new ViewHolder();
			if (convertView == null) {
				convertView = LayoutInflater.from(mContext).inflate(
						R.layout.menu_item, null);
			}
			viewholder.fileImage = (ImageView) convertView
					.findViewById(R.id.Iv);
			viewholder.fileName = (TextView) convertView
					.findViewById(R.id.Tv);
			viewholder.fileImage.setBackgroundResource(fileList.get(position).itemImg);
			viewholder.fileName.setText(fileList.get(position).itemTitle);
			return convertView;
		}
		class ViewHolder {
			ImageView fileImage;
			TextView fileName;
		}
	}
//PopupMenu效果 
	<resources>
		<string name="app_name">Example03_43</string>
		<string name="send">发送邮件</string>
		<string name="look">阅读邮件</string>
		<string name="delete">删除邮件</string>
	</resources>
	<LinearLayout 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"
		android:orientation="vertical">
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击此TextView,显示PopupMenu"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private TextView Tv;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState); // 调用父类的onCreate方法
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			Tv = (TextView)findViewById(R.id.Tv);
		}
		private void setListener() {
			Tv.setOnClickListener(mylistener);
		}
		OnClickListener mylistener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				PopupMenu popup = new PopupMenu(MainActivity.this, v);
				popup.getMenuInflater().inflate(R.menu.main, popup.getMenu());
				popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
					@Override
					public boolean onMenuItemClick(MenuItem item) {
						Toast.makeText(getBaseContext(), "你选择了:" + item.getTitle(), Toast.LENGTH_SHORT).show();
						return true;
					}
				});
				popup.show();
			}
		};
	}
//PopupWindow效果 
	public class MainActivity extends Activity {
		private TextView Tv;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState); // 调用父类的onCreate方法
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			Tv = (TextView)findViewById(R.id.Tv);
		}
		private void setListener() {
			Tv.setOnClickListener(mylistener);
		}
		OnClickListener mylistener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				LayoutInflater lif = (LayoutInflater) (MainActivity.this)
						.getSystemService(LAYOUT_INFLATER_SERVICE);
				View poplayout = lif.inflate(R.layout.activity_popup, null);
				PopupWindow popwindow = new PopupWindow(poplayout,
						LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
				popwindow.setBackgroundDrawable(new BitmapDrawable());
				popwindow.setFocusable(true);
				popwindow.setOutsideTouchable(true);
				popwindow.showAtLocation(findViewById(R.id.LlMain), Gravity.CENTER,
						0, 0);
			}
		};
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:background="@android:color/background_dark"
    android:orientation="vertical" >
		<EditText 
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:textColor="@android:color/white"
			android:hint="请输入用户名:"
			/>
		<EditText 
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:textColor="@android:color/white"
			android:hint="请输入密码:"
			/>
		<Button
			android:id="@+id/BtnLogin"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="登录" />
		<Button
			android:id="@+id/BtnExit"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="退出"/>
	</LinearLayout>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://schemas.android.com/tools"
	android:id="@+id/LlMain" 
	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"
	android:orientation="vertical">
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击此TextView,显示登录PopupWindow"
			/>
	</LinearLayout>
//QQ客户端的标签栏效果 
	<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<LinearLayout
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:orientation="vertical" >
			<TabWidget
				android:id="@android:id/tabs"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content" />
			<FrameLayout
				android:id="@android:id/tabcontent"
				android:layout_width="fill_parent"
				android:layout_height="fill_parent"
				android:padding="5dp" />
		</LinearLayout>
	</TabHost>
	//activity_mydiscussion_item
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >
		<ImageView
			android:id="@+id/Iv"
			android:layout_width="wrap_content"
			android:layout_height="match_parent"
			android:scaleType="fitXY" />
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:layout_marginLeft="10dip"
			android:orientation="vertical" >
			<TextView
				android:id="@+id/TvTitle"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:gravity="left"
				android:textColor="@color/blue"
				android:textSize="20sp" />
			<TextView
				android:id="@+id/TvInfo"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:gravity="left"
				android:textColor="@color/blue"
				android:textSize="10sp" />
		</LinearLayout>
	</LinearLayout>
	//activity_mydiscussion
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
		android:layout_width="match_parent"
		android:layout_height="match_parent" >
		<ListView 
			android:id="@+id/LvDiscussion"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			/>
	</LinearLayout>
	//activity_myfriend_item
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >
		<ImageView
			android:id="@+id/Iv"
			android:layout_width="wrap_content"
			android:layout_height="match_parent" />
		<TextView
			android:id="@+id/TvTitle"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_marginLeft="10dip"
			android:gravity="left"
			android:textColor="@color/blue"
			android:textSize="20sp" />
		<TextView
			android:id="@+id/TvInfo"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:gravity="right"
			android:textColor="@color/blue"
			android:textSize="10sp" />
	</LinearLayout>
	//activity_myfriend
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
		<ListView 
			android:id="@+id/LvFirend"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			/>
	</LinearLayout>
	//activity_mygroup_item
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >
		<ImageView
			android:id="@+id/Iv"
			android:layout_width="wrap_content"
			android:layout_height="match_parent"
			android:scaleType="fitXY" />
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:layout_marginLeft="10dip"
			android:orientation="vertical" >
			<TextView
				android:id="@+id/TvTitle"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:gravity="left"
				android:textColor="@color/blue"
				android:textSize="20sp" />
			<TextView
				android:id="@+id/TvInfo"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:gravity="left"
				android:textColor="@color/blue"
				android:textSize="10sp" />
		</LinearLayout>
	</LinearLayout>
	//activity_mygroup
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
		<ListView 
			android:id="@+id/LvGroup"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			/>
	</LinearLayout>
	//com.wyl.example
	public class MainActivity extends TabActivity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			TabHost tabHost = getTabHost();
			TabHost.TabSpec spec;
			Intent i;
			i = new Intent(this, MyFriendActivity.class);
			spec = tabHost.newTabSpec("0")
					.setIndicator("好友")
					.setContent(i);
			tabHost.addTab(spec);
			i = new Intent(this, MyGroupActivity.class);
			spec = tabHost.newTabSpec("1")
					.setIndicator("群")
					.setContent(i);
			tabHost.addTab(spec);
			i = new Intent(this, MyDiscussionActivity.class);
			spec = tabHost.newTabSpec("2")
					.setIndicator("讨论组")
					.setContent(i);
			tabHost.addTab(spec);
			tabHost.setCurrentTab(1);
		}
	}
	public class MyDiscussionActivity extends Activity {
		private ListView LvFriend;
		private MyDiscussionListAdapter adapter;
		private List<MyDiscussion> l = new ArrayList<MyDiscussion>();

		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_mygroup);
			getData();
			LvFriend = (ListView) findViewById(R.id.LvGroup);
			adapter = new MyDiscussionListAdapter(MyDiscussionActivity.this, l);
			LvFriend.setAdapter(adapter);
		}
		private void getData() {
			l.add(new MyDiscussion("临时讨论组", R.drawable.dicussion, "张三,李四,王五"));
			l.add(new MyDiscussion("项目研讨组", R.drawable.dicussion, "赵六,刘八,池塘的花"));
			l.add(new MyDiscussion("自定义讨论组", R.drawable.dicussion,"shune,黑暗骑士,白雪"));
			l.add(new MyDiscussion("课程讨论组", R.drawable.dicussion, "A1,blue,李经理"));
		}
	}
	public class MyFriendActivity extends Activity {
		private ListView LvFriend;
		private MyFriendListAdapter adapter;
		private List<MyFriend> list = new ArrayList<MyFriend>();
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_myfriend);
			getData();
			LvFriend = (ListView)findViewById(R.id.LvFirend);
			adapter = new MyFriendListAdapter(MyFriendActivity.this, list);
			LvFriend.setAdapter(adapter);
		}
		private void getData() {
			list.add(new MyFriend("在线好友", R.drawable.arrow, "42"));
			list.add(new MyFriend("我的好友", R.drawable.arrow, "33"));
			list.add(new MyFriend("工作好友", R.drawable.arrow, "45"));
			list.add(new MyFriend("同学好友", R.drawable.arrow, "87"));
		}
	}
	public class MyGroupActivity extends Activity {
		private ListView LvGroup;
		private MyGroupListAdapter adapter;
		private List<MyGroup> l = new ArrayList<MyGroup>();
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_mygroup);
			getData();
			LvGroup = (ListView) findViewById(R.id.LvGroup);
			adapter = new MyGroupListAdapter(MyGroupActivity.this, l);
			LvGroup.setAdapter(adapter);
		}
		private void getData() {
			l.add(new MyGroup("工作群", R.drawable.group, "讨论工作中的事情"));
			l.add(new MyGroup("学习群", R.drawable.group, "分享最新学习信息"));
			l.add(new MyGroup("游戏群", R.drawable.group, "游戏共享"));
			l.add(new MyGroup("影视群", R.drawable.group, "最新影评"));
		}
	}
	//com.wyl.example.adapter
	public class MyDiscussionListAdapter extends BaseAdapter {
		private LayoutInflater mInflater;
		private List<MyDiscussion> list = new ArrayList<MyDiscussion>();
		private Context context;
		public MyDiscussionListAdapter(Context c, List<MyDiscussion> l) {
			context = c;
			list = l;
		}
		class ViewHolder {
			ImageView Image;
			TextView Name;
			TextView Number;
		}
		@Override
		public int getCount() {
			return list.size();
		}
		@Override
		public Object getItem(int position) {
			return list.get(position);
		}
		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			ViewHolder viewholder = null;
			if (convertView == null) {
				convertView = LayoutInflater.from(context).inflate(
						R.layout.activity_mydiscussion_item, null);
				viewholder = new ViewHolder();
				viewholder.Image = (ImageView) convertView.findViewById(R.id.Iv);
				viewholder.Name = (TextView) convertView.findViewById(R.id.TvTitle);
				viewholder.Number = (TextView) convertView.findViewById(R.id.TvInfo);

				convertView.setTag(viewholder);
			} else {
				viewholder = (ViewHolder) convertView.getTag();
			}
			viewholder.Image.setBackgroundResource(list.get(position).ImgId);
			viewholder.Name.setText(list.get(position).Name);
			viewholder.Number.setText(list.get(position).Info);
			return convertView;
		}
	}
	public class MyFriendListAdapter extends BaseAdapter {
		private LayoutInflater mInflater;
		private List<MyFriend> list = new ArrayList<MyFriend>();
		private Context context;
		public MyFriendListAdapter(Context c, List<MyFriend> l) {
			context = c;
			list = l;
		}
		class ViewHolder {
			ImageView Image;
			TextView Name;
			TextView Number;
		}
		@Override
		public int getCount() {
			return list.size();
		}
		@Override
		public Object getItem(int position) {
			return list.get(position);
		}
		@Override
		public long getItemId(int position) {
			return position;
		}
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			ViewHolder viewholder = null;
			if (convertView == null) {
				convertView = LayoutInflater.from(context).inflate(
						R.layout.activity_myfriend_item, null);
				viewholder = new ViewHolder();
				viewholder.Image = (ImageView) convertView.findViewById(R.id.Iv);
				viewholder.Name = (TextView) convertView.findViewById(R.id.TvTitle);
				viewholder.Number = (TextView) convertView.findViewById(R.id.TvInfo);
				convertView.setTag(viewholder);
			} else {
				viewholder = (ViewHolder) convertView.getTag();
			}
			viewholder.Image.setBackgroundResource(list.get(position).ImgId);
			viewholder.Name.setText(list.get(position).Name);
			viewholder.Number.setText(list.get(position).Info);
			return convertView;
		}
	}
	public class MyGroupListAdapter extends BaseAdapter {
		private LayoutInflater mInflater;
		private List<MyGroup> list = new ArrayList<MyGroup>();
		private Context context;
		public MyGroupListAdapter(Context c, List<MyGroup> l) {
			context = c;
			list = l;
		}
		class ViewHolder {
			ImageView Image;
			TextView Name;
			TextView Number;
		}
		@Override
		public int getCount() {
			return list.size();
		}
		@Override
		public Object getItem(int position) {
			return list.get(position);
		}
		@Override
		public long getItemId(int position) {
			return position;
		}
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			ViewHolder viewholder = null;
			if (convertView == null) {
				convertView = LayoutInflater.from(context).inflate(
						R.layout.activity_mygroup_item, null);
				viewholder = new ViewHolder();
				viewholder.Image = (ImageView) convertView.findViewById(R.id.Iv);
				viewholder.Name = (TextView) convertView.findViewById(R.id.TvTitle);
				viewholder.Number = (TextView) convertView.findViewById(R.id.TvInfo);
				convertView.setTag(viewholder);
			} else {
				viewholder = (ViewHolder) convertView.getTag();
			}
			viewholder.Image.setBackgroundResource(list.get(position).ImgId);
			viewholder.Name.setText(list.get(position).Name);
			viewholder.Number.setText(list.get(position).Info);
			return convertView;
		}
	}
	//com.wyl.example.moudle
	public class MyDiscussion {
		public String Name;		
		public int ImgId;		
		public String Info;		
		public MyDiscussion() {
			super();
		}
		public MyDiscussion(String n, int imgId, String info) {
			super();
			Name = n;
			ImgId = imgId;
			Info = info;
		}
	}
	public class MyFriend {
		public String Name;		
		public int ImgId;		
		public String Info;		
		public MyFriend() {
			super();
		}
		public MyFriend(String n, int imgId, String info) {
			super();
			Name = n;
			ImgId = imgId;
			Info = info;
		}
	}
	public class MyGroup {
		public String Name;		
		public int ImgId;		
		public String Info;		
		public MyGroup() {
			super();
		}
		public MyGroup(String n, int imgId, String info) {
			super();
			Name = n;
			ImgId = imgId;
			Info = info;
		}
	}
//仿新浪微博的主页效果 
	public class FiveActivity extends Activity {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			this.setContentView(R.layout.activity_five);
		}
	}
	public class FourActivity extends Activity {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			this.setContentView(R.layout.activity_four);
		}
	}
	public class MainActivity extends TabActivity implements OnCheckedChangeListener{
		private TabHost mHost;
		private RadioGroup radioderGroup;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			mHost=this.getTabHost();
			mHost.addTab(mHost.newTabSpec("ONE").setIndicator("ONE")
						.setContent(new Intent(this,OneActivity.class)));
			mHost.addTab(mHost.newTabSpec("TWO").setIndicator("TWO")
					.setContent(new Intent(this,TwoActivity.class)));
			mHost.addTab(mHost.newTabSpec("THREE").setIndicator("THREE")
					.setContent(new Intent(this,ThreeActivity.class)));
			mHost.addTab(mHost.newTabSpec("FOUR").setIndicator("FOUR")
					.setContent(new Intent(this,FourActivity.class)));
			mHost.addTab(mHost.newTabSpec("FIVE").setIndicator("FIVE")
					.setContent(new Intent(this,FiveActivity.class)));
			radioderGroup = (RadioGroup) findViewById(R.id.main_radio);
			radioderGroup.setOnCheckedChangeListener(this);
		}
		@Override
		public void onCheckedChanged(RadioGroup group, int checkedId) {
			switch(checkedId){
			case R.id.radio_button0:
				mHost.setCurrentTabByTag("ONE");
				break;
			case R.id.radio_button1:
				mHost.setCurrentTabByTag("TWO");
				break;
			case R.id.radio_button2:
				mHost.setCurrentTabByTag("THREE");
				break;
			case R.id.radio_button3:
				mHost.setCurrentTabByTag("FOUR");
				break;
			case R.id.radio_button4:
				mHost.setCurrentTabByTag("FIVE");
				break;
			}		
		}
	}
	public class OneActivity extends Activity  {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			this.setContentView(R.layout.activity_one);
		}
	}
	public class ThreeActivity extends Activity {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			this.setContentView(R.layout.activity_three);
		}
	}
	public class TwoActivity extends Activity {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			this.setContentView(R.layout.activity_two);
		}
	}
	//activity_five
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
		<TextView 
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:gravity="center"
			android:text="这是设置Activity"/>
	</LinearLayout>
	//activity_four
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
		<TextView 
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:gravity="center"
			android:text="这是音乐Activity"/>
	</LinearLayout>
	//activity_main
	<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<LinearLayout 
			android:orientation="vertical" 
			android:layout_width="fill_parent" 
			android:layout_height="fill_parent">
			<FrameLayout 
				android:id="@android:id/tabcontent" 
				android:layout_width="fill_parent" 
				android:layout_height="0.0dip" 
				android:layout_weight="1.0" />
			<TabWidget 
				android:id="@android:id/tabs" 
				android:visibility="gone" 
				android:layout_width="fill_parent" 
				android:layout_height="wrap_content" 
				android:layout_weight="0.0" />
			<RadioGroup 
				android:gravity="center_vertical" 
				android:layout_gravity="bottom" 
				android:orientation="horizontal" 
				android:id="@+id/main_radio" 
				android:background="@drawable/maintab_toolbar_bg" 
				android:layout_width="fill_parent" 
				android:layout_height="wrap_content">
				<RadioButton 
					android:id="@+id/radio_button0" 
					android:tag="radio_button0" 
					android:layout_marginTop="2.0dip" 
					android:text="@string/friend" 
					android:drawableTop="@drawable/icon_1" 
					style="@style/main_tab_bottom" />
				<RadioButton 
					android:id="@+id/radio_button1" 
					android:tag="radio_button1" 
					android:layout_marginTop="2.0dip" 
					android:text="@string/cast" 
					android:drawableTop="@drawable/icon_2" 
					style="@style/main_tab_bottom" />
				<RadioButton 
					android:id="@+id/radio_button2" 
					android:tag="radio_button2" 
					android:layout_marginTop="2.0dip" 
					android:text="@string/main" 
					android:drawableTop="@drawable/icon_3" 
					style="@style/main_tab_bottom" />
				<RadioButton 
					android:id="@+id/radio_button3" 
					android:tag="radio_button3" 
					android:layout_marginTop="2.0dip" 
					android:text="@string/msg" 
					android:drawableTop="@drawable/icon_4" 
					style="@style/main_tab_bottom" />
				<RadioButton 
					android:id="@+id/radio_button4" 
					android:tag="radio_button4" 
					android:layout_marginTop="2.0dip" 
					android:text="@string/more" 
					android:drawableTop="@drawable/icon_5" 
					style="@style/main_tab_bottom" />
			</RadioGroup>
		</LinearLayout>
	</TabHost>
	//activity_one
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="top|center"
    android:orientation="vertical" >
		<TextView 
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:gravity="center"
			android:text="这是时间Activity"/>
	</LinearLayout>
	//activity_three
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
		<TextView 
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:gravity="center"
			android:text="这是图片Activity"/>
	</LinearLayout>
	//activity_two
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
		android:orientation="vertical"
		android:layout_width="fill_parent"
		android:layout_height="fill_parent"
		>
		<TextView 
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:gravity="center"
			android:text="这是信息Activity"/>
	</LinearLayout>
//程序退出的对话框 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:text="点击物理返回键弹出退出对话框" />
	</LinearLayout>
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
		}
		protected void creatdialog() {
			AlertDialog.Builder b = new Builder(MainActivity.this);
			b.setMessage("确认退出吗?");
			b.setTitle("提示");
			b.setPositiveButton("确认", new OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
					MainActivity.this.finish();
				}
			});
			b.setNegativeButton("取消", new OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
				}
			});
			b.create().show();
		}
		public boolean onKeyDown(int keyCode, KeyEvent event) {
			if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
				creatdialog();
			}
			return false;
		}
	}
//程序的关于对话框 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:text="点击物理菜单键弹出关于对话框" />
	</LinearLayout>
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
		}
		protected void creatdialog() {
			AlertDialog.Builder builder = new Builder(MainActivity.this);
			builder.setMessage("本程序是V1.0版本,如有问题请及时提出!");
			TextView tv = new TextView(MainActivity.this);
			tv.setGravity(android.view.Gravity.CENTER_HORIZONTAL);
			tv.setText("关于");
			tv.setTextSize(30);
			AlertDialog a = builder.create();
			a.setCustomTitle(tv);
			a.show();
		}
		public boolean onKeyDown(int keyCode, KeyEvent event) {
			if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
				creatdialog();
			}
			return false;
		}
	}
//电话服务评价对话框 
	public class MainActivity extends Activity {
		private TextView Tv;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			Tv = (TextView)findViewById(R.id.Tv);
		}
		protected void creatdialog() {
			Dialog dialog = new AlertDialog.Builder(this)
					.setIcon(android.R.drawable.btn_dialog).setTitle("评价对话框")
					.setMessage("请对我的服务进行评价:")
					.setPositiveButton("很好", new OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							Tv.setText("很好");
						}
					}).setNegativeButton("一般", new OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							Tv.setText("一般");
						}
					}).setNeutralButton("有待改进", new OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							Tv.setText("有待改进");
						}
					}).create();
			dialog.show();
		}
		public boolean onKeyDown(int keyCode, KeyEvent event) {
			if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
				creatdialog();
			}
			return false;
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:text="点击物理返回键弹出评价对话框" />
	</LinearLayout>
//数据加载成功的提示 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:text="等待数据加载......" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private TextView Tv;
		private final int HANDLER_TEST = 0;
		private Handler h = new Handler(){
			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);
				switch (msg.what) {
				case HANDLER_TEST:
					Toast.makeText(MainActivity.this, "数据加载完毕", Toast.LENGTH_SHORT).show();
					Tv.setText("数据加载完毕");
					break;
				}
			}
		};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			Tv = (TextView)findViewById(R.id.Tv);
			new Thread(){
				@Override
				public void run() {
					super.run();
					try {
						sleep(5000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					Message msg = new Message();
					msg.what = HANDLER_TEST;
					h.sendMessage(msg);
				}
			}.start();
		}
	}
//网络图片加载成功的提示 
	public class MainActivity extends Activity {
		private ImageView Iv;
		private final int SUCCESS = 0;
		private final int FAILED = 1;
		private final String url = "http://www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif";
		private Bitmap bit = null;
		private Handler h = new Handler(){
			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);
				switch (msg.what) {
				case SUCCESS:
					Toast.makeText(MainActivity.this, "图片加载成功!", Toast.LENGTH_SHORT).show();
					Iv.setImageBitmap(bit);
					break;
				case FAILED:
					Toast.makeText(MainActivity.this, "数据加载失败!", Toast.LENGTH_SHORT).show();
					break;
				}
			}
		};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			Iv = (ImageView)findViewById(R.id.Iv);
			if (isOpenNetwork()) {
				new Thread(){
					@Override
					public void run() {
						super.run();
						try {
							bit = getRemoteImage(new URL(url));
						} catch (MalformedURLException e) {
							e.printStackTrace();
						}
						if (bit != null) {
							Message msg = new Message();
							msg.what = SUCCESS;
							h.sendMessage(msg);
						}
						else{
							Message msg = new Message();
							msg.what = FAILED;
							h.sendMessage(msg);
						}
					}
				}.start();
			}
			else{
				Toast.makeText(MainActivity.this, "网络不通!", Toast.LENGTH_SHORT).show();
			}
		}
		public Bitmap getRemoteImage(final URL aURL) {
			try {
				final URLConnection conn = aURL.openConnection();
				conn.connect();
				final BufferedInputStream bis = new BufferedInputStream(
						conn.getInputStream());
				final Bitmap bm = BitmapFactory.decodeStream(bis);
				bis.close();
				return bm;
			} catch (IOException e) {
				Log.d("DEBUGTAG", "Oh noooz an error...");
			}
			return null;
		}
		private boolean isOpenNetwork() {
			ConnectivityManager connManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
			if(connManager.getActiveNetworkInfo() != null) {
				return connManager.getActiveNetworkInfo().isAvailable();
			}
			return false;
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<ImageView
			android:id="@+id/Iv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:src="@drawable/ic_launcher" />
	</LinearLayout>
//模拟收到短信的状态栏提示 
	public class MainActivity extends Activity {
		private Button Btn;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			Btn = (Button) findViewById(R.id.Btn);
			Btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					sendNotificaction();
				}
			});
		}
		private void sendNotificaction() {
			NotificationManager manager = (NotificationManager) this
					.getSystemService(Context.NOTIFICATION_SERVICE);
			Notification notification = new Notification();
			notification.icon = R.drawable.ic_launcher;
			notification.tickerText = "您有一条新的短消息!";
			notification.defaults = Notification.DEFAULT_SOUND;
			notification.audioStreamType = android.media.AudioManager.ADJUST_LOWER;
			Intent intent = new Intent(this, MainActivity.class);
			PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
					intent, PendingIntent.FLAG_ONE_SHOT);
			notification.setLatestEventInfo(this, "短消息内容", "我是一个短消息,愚人节快乐!",
					pendingIntent);
			manager.notify(1, notification);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<Button
			android:id="@+id/Btn"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="点击发送Notification信息!" />
	</LinearLayout>
//模拟数据下载的状态栏提示 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<Button
			android:id="@+id/BtnSend"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="发送下载Notification" />
		<Button
			android:id="@+id/BtnClean"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="清除Notification" />
	</LinearLayout>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="wrap_content"
			android:layout_height="fill_parent"
			android:text="下载中"
			android:textColor="@android:color/white"
			android:textSize="20sp" />
		<ProgressBar
			android:id="@+id/Pb"
			style="?android:attr/progressBarStyleHorizontal"
			android:layout_width="260dip"
			android:layout_height="wrap_content"
			android:layout_gravity="center_vertical" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private int notification_id = 1;
		private NotificationManager nm;
		private Handler handler = new Handler();
		private Notification notification;
		private int count = 0;
		private Boolean isclean = false;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			Button BtnSend = (Button) findViewById(R.id.BtnSend);
			BtnSend.setOnClickListener(mylis);
			Button BtnClean = (Button) findViewById(R.id.BtnClean);
			BtnClean.setOnClickListener(mylis);
			nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
			notification = new Notification(R.drawable.ic_launcher, "开始下载",
					System.currentTimeMillis());
			notification.contentView = new RemoteViews(getPackageName(),
					R.layout.layout_notification);
			notification.contentView.setProgressBar(R.id.Pb, 100, 0, false);
			Intent notificationIntent = new Intent(this, MainActivity.class);
			PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
					notificationIntent, 0);
			notification.contentIntent = contentIntent;
		}
		OnClickListener mylis = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.BtnClean:
					nm.cancel(notification_id);
					isclean = true;
					break;
				case R.id.BtnSend:
					showNotification();
					handler.post(run);
					break;
				default:
					break;
				}
			}
		};
		Runnable run = new Runnable() {
			@Override
			public void run() {
				if (!isclean) {
					count++;
					notification.contentView.setProgressBar(R.id.Pb, 100, count,
							false);
					showNotification();
					if (count < 100)
						handler.postDelayed(run, 200);
				}
			}
		};
		public void showNotification() {
			nm.notify(notification_id, notification);
		}
	}
	
让你的程序和用户说话
Android中基于回调函数的事件处理 
//Activity的声明周期回调 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="Activity生命周期演示,请查看logcat" />
	</LinearLayout>
	public class MainActivity extends Activity {
		public static final String TAG = "Activity Life Cycle";
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			Log.e(TAG, "onCreate");
		}
		@Override
		protected void onDestroy() {
			super.onDestroy();
			Log.e(TAG, "onDestroy");
		}
		@Override
		protected void onPause() {
			super.onPause();
			Log.e(TAG, "onPause");
		}
		@Override
		protected void onRestart() {
			super.onRestart();
			Log.e(TAG, "onRestart");
		}
		@Override
		protected void onResume() {
			super.onResume();
			Log.e(TAG, "onResume");
		}
		@Override
		protected void onStart() {
			super.onStart();
			Log.e(TAG, "onStart");
		}
		@Override
		protected void onStop() {
			super.onStop();
			Log.e(TAG, "onStop");
		}
	}
//用户名长度检测效果 
	public class MainActivity extends Activity {
		private TextView Tv;
		private EditText Et;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
		}
		private void findView() {
			Tv = (TextView)findViewById(R.id.Tv);
			Et = (EditText)findViewById(R.id.Et);
		}
		public void myclick(View v){
			int len = Et.getText().toString().length();
			if (len > 5 && len < 9) {
				Tv.setText("用户名合法");
			}else{
				Tv.setText("用户名长度非法");
			}
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<EditText
			android:id="@+id/Et"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:hint="请输入用户名:"/>
		<Button
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:onClick="myclick"
			android:text="点击我,检测用户名合法性!"/>
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"/>
	</LinearLayout>
//打字游戏实现 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:text="i have a dream that one day this nation will rise up and live out the true meaning of its creed , we hold these truths to be self-evident, that all men are created equal."
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private TextView Tv;
		private int count = 1;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
		}
		@Override
		public boolean onKeyDown(int keyCode, KeyEvent event) {
			char ch = Character.toLowerCase(event.getDisplayLabel());
			if (ch == Tv.getText().charAt(count-1) 
					&& event.getAction() == KeyEvent.ACTION_DOWN) {
				SpannableString ss = new SpannableString(Tv.getText().toString());
				ss.setSpan(new ForegroundColorSpan(Color.RED), 
						0, count,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
				ss.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 
						0, count,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
				count++;
				Tv.setText(ss);
			}
			return super.onKeyDown(keyCode, event);
		}
		private void findView() {
			Tv = (TextView)findViewById(R.id.Tv);
		}
	}
//长按播放TextView动画 
	<set xmlns:android="http://schemas.android.com/apk/res/android" >
		<scale
			android:duration="3000"
			android:fromXScale="0.0"
			android:fromYScale="0.0"
			android:interpolator="@android:anim/decelerate_interpolator"
			android:repeatCount="1"
			android:startOffset="0"
			android:toXScale="1.5"
			android:toYScale="1.5" />
	</set>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:text="长按S键播放Tv的动画"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private TextView Tv;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
		}
		@Override
		public boolean onKeyDown(int keyCode, KeyEvent event) {
			event.startTracking();
			return true;
		}
		@Override
		public boolean onKeyLongPress(int keyCode, KeyEvent event) {
			char ch = Character.toLowerCase(event.getDisplayLabel());
			if ('s'== ch) {
				Animation scale=AnimationUtils.loadAnimation(MainActivity.this, R.anim.anim);
				Tv.startAnimation(scale);
			}
			return super.onKeyLongPress(keyCode, event);
		}
		private void findView() {
			Tv = (TextView)findViewById(R.id.Tv);
		}
	}
//按钮的快捷键 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="点击按钮或点击A键都可触发Button的点击事件"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:onClick="myclick"
			android:text="点击(A)"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button Btn;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
		}
		@Override
		public boolean onKeyDown(int keyCode, KeyEvent event) {
			char ch = Character.toLowerCase(event.getDisplayLabel());
			if ('a'== ch) {
				myclick(Btn);
			}
			return super.onKeyDown(keyCode, event);
		}
		public void myclick(View v){
			Toast.makeText(MainActivity.this, "按钮被点击了...", Toast.LENGTH_SHORT).show();
		}
		private void findView() {
			Btn = (Button)findViewById(R.id.Btn);
		}
	}
//屏幕单击测试器 
	public class MainActivity extends Activity {
		private TextView Tv;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
		}
		@Override
		public boolean onTouchEvent(MotionEvent event) {
			if (MotionEvent.ACTION_DOWN == event.getAction()) {
				float x = event.getX();
				float y = event.getY();
				Tv.setText("您点击的位置是:\nx:"+x+"\n y:"+y);
			}
			return super.onTouchEvent(event);
		}
		private void findView() {
			Tv = (TextView)findViewById(R.id.Tv);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="点击屏幕得到相对屏幕的位置"
			/>
	</LinearLayout>
//Activity内容加载完毕提示 
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
		}
		@Override
		public void onWindowFocusChanged(boolean hasFocus) {
			super.onWindowFocusChanged(hasFocus);
			if(hasFocus) 
			{
				Toast t = Toast.makeText(MainActivity.this, 
						"页面加载完毕",Toast.LENGTH_SHORT);
				t.setGravity(Gravity.CENTER, 0, 0);
				t.show();
			}
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="页面加载完毕后显示Toast提示框"
			/>
	</LinearLayout>
//横竖界面自动切换 
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
		}
		@Override
		public void onConfigurationChanged(Configuration newConfig) {
			super.onConfigurationChanged(newConfig);
			if(newConfig.orientation==Configuration.ORIENTATION_PORTRAIT){
				Toast.makeText(MainActivity.this, "现在是竖屏", Toast.LENGTH_SHORT).show();
				setContentView(R.layout.activity_main);
			}else if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE){
				Toast.makeText(MainActivity.this, "现在是横屏", Toast.LENGTH_SHORT).show();
				setContentView(R.layout.activity_main_horizontal);
			}
		}
	}
	//activity_main_horizontal
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="我是横向布局"
			/>
	</LinearLayout>
	//activity_main
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="我是纵向布局"
			/>
	</LinearLayout>
//动态添加联系人列表 
	public class MainActivity extends Activity {
		private Button Btn;
		private LinearLayout Ll;
		private int count = 0;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			Btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					addEditText();
				}
			});
		}
		@Override
		public void onContentChanged() {
			super.onContentChanged();
			Toast.makeText(MainActivity.this, 
					"已经添加了"+count+"个联系人!", 
					Toast.LENGTH_SHORT).show();
			count++;
		}
		private void addEditText(){
			EditText e = new EditText(MainActivity.this);
			e.setHint("请输入第"+count+"个联系人的信息!");
			Ll.addView(e);
			setContentView(Ll);
		}
		private void findView() {
			Btn = (Button)findViewById(R.id.Btn);
			Ll = (LinearLayout)findViewById(R.id.Ll);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/Ll"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<Button
			android:id="@+id/Btn"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="点击动态添加联系人"
			/>
	</LinearLayout>
Android中基于监听器的事件处理
//宝宝看图识字软件 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:textSize="20dip"
			android:text="请选出如下图形:"
			/>
		<LinearLayout 
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal"
			>
				<TextView
					android:id="@+id/TvRed"
					android:layout_width="fill_parent"
					android:layout_height="100dip"
					android:background="@color/red"
					android:layout_weight="1"
					/>
				<TextView
					android:id="@+id/TvGreen"
					android:layout_width="fill_parent"
					android:layout_height="100dip"
					android:background="@color/green"
					android:layout_weight="1"
					/>
				<TextView
					android:id="@+id/TvBlue"
					android:layout_width="fill_parent"
					android:layout_height="100dip"
					android:background="@color/blue"
					android:layout_weight="1"
					/>
		</LinearLayout>
		<LinearLayout 
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal"
			>
				<TextView
					android:id="@+id/TvRat"
					android:layout_width="fill_parent"
					android:layout_height="100dip"
					android:background="@drawable/rat"
					android:layout_weight="1"
					/>
				<TextView
					android:id="@+id/TvElephant"
					android:layout_width="fill_parent"
					android:layout_height="100dip"
					android:background="@drawable/elephant"
					android:layout_weight="1"
					/>
				<TextView
					android:id="@+id/TvTiger"
					android:layout_width="fill_parent"
					android:layout_height="100dip"
					android:background="@drawable/tiger"
					android:layout_weight="1"
					/>
		</LinearLayout>
	</LinearLayout>
	public class MainActivity extends Activity {
		private TextView Tv;
		private TextView TvRed;
		private TextView TvBlue;
		private TextView TvGreen;
		private TextView TvTiger;
		private TextView TvRat;
		private TextView TvElephant;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			TvBlue.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Tv.setText("您选择了蓝色!");
				}
			});
			TvRed.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Tv.setText("您选择了红色!");
				}
			});
			TvGreen.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Tv.setText("您选择了绿色!");
				}
			});
			TvTiger.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Tv.setText("您选择了老虎!");
				}
			});
			TvElephant.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Tv.setText("您选择了大象!");
				}
			});
			TvRat.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					//设置对应的文字
					Tv.setText("您选择了老鼠!");
				}
			});
		}
		private void findView() {
			Tv = (TextView)findViewById(R.id.Tv);
			TvBlue = (TextView)findViewById(R.id.TvBlue);
			TvRed = (TextView)findViewById(R.id.TvRed);
			TvGreen = (TextView)findViewById(R.id.TvGreen);
			TvElephant = (TextView)findViewById(R.id.TvElephant);
			TvTiger = (TextView)findViewById(R.id.TvTiger);
			TvRat = (TextView)findViewById(R.id.TvRat);
		}
	}
//控件的拖动效果 
	<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
    android:orientation = "vertical"
    android:layout_width = "fill_parent"
    android:layout_height = "fill_parent"
    >
		<com.wyl.example.AreaOne
			android:id = "@+id/ViewOne"
			android:layout_width = "50dip"
			android:layout_height = "50dip"
			android:background = "#FFFF00"
			/>
		<TextView
			android:layout_width = "50dip"
			android:layout_height = "50dip"
			/>
		<com.wyl.example.AreaTwo
			android:id = "@+id/ViewTwo"
			android:layout_width = "50dip"
			android:layout_height = "50dip"
			android:background = "#00FF00"
			/>
	</LinearLayout>
	public class AreaOne extends View {
		public AreaOne(Context context) {
			super(context);
		}
		public AreaOne(Context context, AttributeSet attrs) {
			super(context, attrs);
		}
	}
	public class AreaTwo extends View {
		public AreaTwo(Context context) {
			super(context);
		}
		public AreaTwo(Context context, AttributeSet attrs) {
			super(context, attrs);
		}
	}
	public class MainActivity extends Activity {
		public View ViewOne;
		public View ViewTwo;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			ViewOne.setOnLongClickListener(new OnLongClickListener() {
				public boolean onLongClick(View view) {
					ViewOne.startDrag(null, new DragShadowBuilder(view),
							(Object) view, 0);
					return true;
				}
			});
			ViewTwo.setOnDragListener(new OnDragListener() {
				public boolean onDrag(View mDropView, DragEvent event) {
					boolean result = false;
					switch (event.getAction()) {
					case DragEvent.ACTION_DRAG_STARTED: {
						Log.e("OnDragListener", "View开始被拖动!");
						result = true;
						break;
					}
					case DragEvent.ACTION_DRAG_ENTERED: {
						Log.e("OnDragListener", "被拖动的View进入当前View!");
						break;
					}
					case DragEvent.ACTION_DRAG_LOCATION: {
						Log.e("OnDragListener", "被拖动的View进入当前View后,位置发生改变!");
						break;
					}
					case DragEvent.ACTION_DROP: {
						Log.e("OnDragListener", "拖动的View被放入当前View!");
						View mDragView = (View) event.getLocalState();
						Drawable mDragViewBackgroud = mDragView.getBackground();
						mDragView.setBackgroundDrawable(mDropView.getBackground());
						mDropView.setBackgroundDrawable(mDragViewBackgroud);
						break;
					}
					case DragEvent.ACTION_DRAG_ENDED: {
						Log.e("OnDragListener", "拖动结束!");
						break;
					}
					case DragEvent.ACTION_DRAG_EXITED: {
						Log.e("OnDragListener", "拖动退出!");
						break;
					}
					default: {
						break;
					}
					}
					return result;
				}
			});
		}
		private void findView() {
			ViewOne = findViewById(R.id.ViewOne);
			ViewTwo = findViewById(R.id.ViewTwo);
		}
	}
//Email格式的检测 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
		<TextView
			android:id="@+id/showInfo"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:text="请输入Email:" />
		<EditText 
			android:id="@+id/inputInfo"
			android:layout_width="200dip"
			android:layout_height="wrap_content"
			android:selectAllOnFocus="true"/>
		<ImageView 
			android:id="@+id/showImg"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private EditText Tvinput = null;
		private ImageView Iv = null;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			Tvinput.setOnKeyListener(new View.OnKeyListener() {
				@Override
				public boolean onKey(View v, int keyCode, KeyEvent event) {
					switch (event.getAction()) {// 得到操作类型
					case KeyEvent.ACTION_DOWN://键盘按下
						String inputString = Tvinput.getText().toString();//获得输入框的内容
						if (inputString.matches("\\w+@\\w+\\.\\w+")) {//验证通过
							Iv.setImageResource(R.drawable.right);//设置为正确的图片
						}else {
							Iv.setImageResource(R.drawable.wrong);//设置为错误的图片
						}
						break;
					case KeyEvent.ACTION_UP://键盘弹起
	 
						break;
					}
					return false;
				}
			});
		}
		private void findView() {
			Tvinput = (EditText) findViewById(R.id.inputInfo);
			Iv = (ImageView) findViewById(R.id.showImg);
		}
	}
//隐藏导航栏 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:text="点击屏幕,隐藏或显示导航栏!" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private TextView Tv;
		private View rootView;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			Tv.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View paramView) {
					int i = rootView.getSystemUiVisibility();  
					Log.e("setOnClickListener", i+"");
					if (i == View.SYSTEM_UI_FLAG_VISIBLE) {  
						rootView.setSystemUiVisibility(
								View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);  
					} 
				}
			});
			rootView.setOnSystemUiVisibilityChangeListener(
					new OnSystemUiVisibilityChangeListener() {
				@Override
				public void onSystemUiVisibilityChange(int visibility) {
					Log.e("onSystemUiVisibilityChange", visibility+"");
					if (visibility == View.VISIBLE) {
						Toast.makeText(MainActivity.this,
								"显示虚拟导航按钮!", 
								Toast.LENGTH_SHORT).show();
					}
					else{
						Toast.makeText(MainActivity.this,
								"隐藏虚拟导航按钮!",
								Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
		private void findView() {
			rootView=getWindow().getDecorView();
			rootView.setSystemUiVisibility(
					View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
			Tv = (TextView)findViewById(R.id.Tv);
		}
	}
//屏幕多点触摸测试器 
	public class MyView extends SurfaceView implements SurfaceHolder.Callback {  
		private static final int MAX_TOUCHPOINTS = 10;  
		private static final String START_TEXT = "请单点或多点触摸屏幕进行测试";  
		private Paint textPaint = new Paint();  
		private Paint touchPaints[] = new Paint[MAX_TOUCHPOINTS];  
		private int colors[] = new int[MAX_TOUCHPOINTS];  
		private int width, height;  
		private float scale = 1.0f;  
		public MyView(Context context) {  
			super(context);  
			SurfaceHolder holder = getHolder();  
			holder.addCallback(this);
			setFocusable(true); 
			setFocusableInTouchMode(true); 
			init();  
		}  
		private void init() {  
			textPaint.setColor(Color.WHITE);  
			colors[0] = Color.BLUE;  
			colors[1] = Color.RED;  
			colors[2] = Color.GREEN;  
			colors[3] = Color.YELLOW;  
			colors[4] = Color.CYAN;  
			colors[5] = Color.MAGENTA;  
			colors[6] = Color.DKGRAY;  
			colors[7] = Color.WHITE;  
			colors[8] = Color.LTGRAY;  
			colors[9] = Color.GRAY;  
			for (int i = 0; i < MAX_TOUCHPOINTS; i++) {  
				touchPaints[i] = new Paint();  
				touchPaints[i].setColor(colors[i]);  
			}  
		}  
	   
		@Override  
		public boolean onTouchEvent(MotionEvent event) {  
			int pointerCount = event.getPointerCount();  
			if (pointerCount > MAX_TOUCHPOINTS) {  
				pointerCount = MAX_TOUCHPOINTS;  
			}  
			Canvas c = getHolder().lockCanvas();  
			if (c != null) {  
				c.drawColor(Color.BLACK);  
				if (event.getAction() == MotionEvent.ACTION_UP) {  
				} else {  
					for (int i = 0; i < pointerCount; i++) {  
						int id = event.getPointerId(i);  
						int x = (int) event.getX(i);  
						int y = (int) event.getY(i);  
						drawCrosshairsAndText(x, y, 
								touchPaints[id], i, id, c);  
					}  
					for (int i = 0; i < pointerCount; i++) {  
						int id = event.getPointerId(i);  
						int x = (int) event.getX(i);  
						int y = (int) event.getY(i);  
						drawCircle(x, y, touchPaints[id], c);  
					}  
				}  
				getHolder().unlockCanvasAndPost(c);  
			}  
			return true;  
		}  
		private void drawCrosshairsAndText(int x, int y, Paint paint, int ptr,  
				int id, Canvas c) {
			c.drawLine(0, y, width, y, paint);  
			c.drawLine(x, 0, x, height, paint);  
			int textY = (int) ((15 + 20 * ptr) * scale);  
			c.drawText("x" + ptr + "=" + x,
					10 * scale, textY, textPaint);  
			c.drawText("y" + ptr + "=" + y,
					70 * scale, textY, textPaint);  
			c.drawText("id" + ptr + "=" + id,
					width - 55 * scale, textY, textPaint);  
		}  
	   
		private void drawCircle(int x, int y, Paint paint, Canvas c) { 
			c.drawCircle(x, y, 20 * scale, paint);  
		}  
		public void surfaceChanged(SurfaceHolder holder, int format, int width,  
				int height) {  
			this.width = width;  
			this.height = height;  
			if (width > height) {  
				this.scale = width / 480f;  
			} else {  
				this.scale = height / 480f;  
			}  
			textPaint.setTextSize(14 * scale);  
			Canvas c = getHolder().lockCanvas();  
			if (c != null) {  
				c.drawColor(Color.BLACK);  
				float tWidth = textPaint.measureText(START_TEXT);  
				c.drawText(START_TEXT, 
						width / 2 - tWidth / 2, height / 2,  
						textPaint);  
				getHolder().unlockCanvasAndPost(c);  
			}  
		}  
		public void surfaceCreated(SurfaceHolder holder) {  
		}  
		public void surfaceDestroyed(SurfaceHolder holder) {  
		}
	}  
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			requestWindowFeature(Window.FEATURE_NO_TITLE);
			getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
					WindowManager.LayoutParams.FLAG_FULLSCREEN);
			setContentView(new MyView(this));
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:text="点击屏幕,隐藏或显示导航栏!" />
	</LinearLayout>
//图片的平移、缩放和旋转 
	public class MyView extends ImageView {
		private float x_down = 0;
		private float y_down = 0;
		private PointF start = new PointF();
		private PointF mid = new PointF();
		private float oldDist = 1f;
		private float oldRotation = 0;
		private Matrix matrix = new Matrix();
		private Matrix matrix1 = new Matrix();
		private Matrix savedMatrix = new Matrix();
		private static final int NONE = 0;
		private static final int DRAG = 1;
		private static final int ZOOM = 2;
		private int mode = NONE;
		private boolean matrixCheck = false;
		private int widthScreen;
		private int heightScreen;
		private Bitmap kenan;
		public MyView(Activity activity) {
			super(activity);
			kenan = BitmapFactory.
					decodeResource(getResources(), R.drawable.kenan);
			DisplayMetrics dm = new DisplayMetrics();
			activity.getWindowManager().
				getDefaultDisplay().getMetrics(dm);
			widthScreen = dm.widthPixels;
			heightScreen = dm.heightPixels;
			matrix = new Matrix();
		}
		protected void onDraw(Canvas canvas) {
			canvas.save();
			canvas.drawBitmap(kenan, matrix, null);
			canvas.restore();
		}
		public boolean onTouchEvent(MotionEvent event) {
			switch (event.getAction() & MotionEvent.ACTION_MASK) {
			case MotionEvent.ACTION_DOWN:
				mode = DRAG;
				x_down = event.getX();
				y_down = event.getY();
				savedMatrix.set(matrix);
				break;
			case MotionEvent.ACTION_POINTER_DOWN:
				mode = ZOOM;
				oldDist = spacing(event);
				oldRotation = rotation(event);
				savedMatrix.set(matrix);
				midPoint(mid, event);
				break;
			case MotionEvent.ACTION_MOVE:
				if (mode == ZOOM) {
					matrix1.set(savedMatrix);
					float rotation = 
							rotation(event) - oldRotation;
					float newDist = spacing(event);
					float scale = newDist / oldDist;
					matrix1.postScale(scale, scale, mid.x, mid.y);
					matrix1.postRotate(rotation, mid.x, mid.y);
					matrixCheck = matrixCheck();
					if (matrixCheck == false) {
						matrix.set(matrix1);
						invalidate();
					}
				} else if (mode == DRAG) {
					matrix1.set(savedMatrix);
					matrix1.postTranslate(event.getX() - x_down
							, event.getY() - y_down);
					matrixCheck = matrixCheck();
					matrixCheck = matrixCheck();
					if (matrixCheck == false) {
						matrix.set(matrix1);
						invalidate();
					}
				}
				break;
			case MotionEvent.ACTION_UP:
			case MotionEvent.ACTION_POINTER_UP:
				mode = NONE;
				break;
			}
			return true;
		}
		private boolean matrixCheck() {
			float[] f = new float[9];
			matrix1.getValues(f);
			float x1 = f[0] * 0 + f[1] * 0 + f[2];
			float y1 = f[3] * 0 + f[4] * 0 + f[5];
			float x2 = f[0] * kenan.getWidth()
					+ f[1] * 0 + f[2];
			float y2 = f[3] * kenan.getWidth()
					+ f[4] * 0 + f[5];
			float x3 = f[0] * 0 + f[1] * 
					kenan.getHeight() + f[2];
			float y3 = f[3] * 0 + f[4] * 
					kenan.getHeight() + f[5];
			float x4 = f[0] * kenan.getWidth() +
					f[1] * kenan.getHeight() + f[2];
			float y4 = f[3] * kenan.getWidth() + 
					f[4] * kenan.getHeight() + f[5];
			double width = Math.sqrt((x1 - x2) *
					(x1 - x2) + (y1 - y2) * (y1 - y2));
			if (width < widthScreen / 3 || width > widthScreen * 3) {
				return true;
			}
			if ((x1 < widthScreen / 3 && x2 < widthScreen / 3
					&& x3 < widthScreen / 3 
					&& x4 < widthScreen / 3)
					|| (x1 > widthScreen * 2 / 3 
							&& x2 > widthScreen * 2 / 3
							&& x3 > widthScreen * 2 / 3 
							&& x4 > widthScreen * 2 / 3)
					|| (y1 < heightScreen / 3 
							&& y2 < heightScreen / 3
							&& y3 < heightScreen / 3 
							&& y4 < heightScreen / 3)
					|| (y1 > heightScreen * 2 / 3 
							&& y2 > heightScreen * 2 / 3
							&& y3 > heightScreen * 2 / 3 
							&& y4 > heightScreen * 2 / 3)) {
				return true;
			}
			return false;
		}
		private float spacing(MotionEvent event) {
			float x = event.getX(0) - event.getX(1);
			float y = event.getY(0) - event.getY(1);
			return FloatMath.sqrt(x * x + y * y);
		}
		private void midPoint(PointF point, MotionEvent event) {
			float x = event.getX(0) + event.getX(1);
			float y = event.getY(0) + event.getY(1);
			point.set(x / 2, y / 2);
		}
		private float rotation(MotionEvent event) {
			double delta_x = (event.getX(0) - event.getX(1));
			double delta_y = (event.getY(0) - event.getY(1));
			double radians = Math.atan2(delta_y, delta_x);
			return (float) Math.toDegrees(radians);
		}
	}
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			MyView myview = new MyView(this);
			setContentView(myview);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:text="点击屏幕,隐藏或显示导航栏!" />
	</LinearLayout>
//图片浏览器滑动切换图片 
	public class MainActivity extends Activity {
		private ImageView Iv;
		private GestureDetector gestureDetector;
		private int[] ResId = new int[]{
			R.drawable.k1,
			R.drawable.k2,
			R.drawable.k3
		};
		private int count = 0;

		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);

			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			gestureDetector = new GestureDetector(MainActivity.this,
					onGestureListener);
		}
		@Override
		public boolean onTouchEvent(MotionEvent event) {
			return gestureDetector.onTouchEvent(event);
		}
		private void findView() {
			Iv = (ImageView) findViewById(R.id.Iv);
		}
		private GestureDetector.OnGestureListener onGestureListener
				= new GestureDetector.SimpleOnGestureListener() {
			@Override
			public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
					float velocityY) {
				float x = e2.getX() - e1.getX();
				float y = e2.getY() - e1.getY();
				if (x > 0) {
					count++;
					count %= 3;
				} else if (x < 0) {
					count--;
					count = (count + 3) % 3;
				}
				changeImg();
				return true;
			}
		};
		public void changeImg() {
			Iv.setImageResource(ResId[count]);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
		<ImageView
			android:id="@+id/Iv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:src="@drawable/k1" />
	</LinearLayout>
//简易画板 
	public class MyView extends View {
		private int mLastX, mLastY; 
		private int mCurrX, mCurrY; 
		private Bitmap mBitmap; 	
		private Paint mPaint;
		public MyView(Context context) {
			super(context);
			mPaint = new Paint();
			mPaint.setStrokeWidth(6);
		}
		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);
			int width = getWidth();
			int height = getHeight();
			if (mBitmap == null) {
				mBitmap = Bitmap.createBitmap(width, height,
						Bitmap.Config.ARGB_8888);
			}
			Canvas tmpCanvas = new Canvas(mBitmap);
			tmpCanvas.drawLine(mLastX, mLastY, mCurrX, mCurrY, mPaint);
			canvas.drawBitmap(mBitmap, 0, 0, mPaint);
		}
		@Override
		public boolean onTouchEvent(MotionEvent event) {
			mLastX = mCurrX;
			mLastY = mCurrY;
			mCurrX = (int) event.getX();
			mCurrY = (int) event.getY();
			switch (event.getAction()) {
			case MotionEvent.ACTION_DOWN:
				mLastX = mCurrX;
				mLastY = mCurrY;
				break;
			default:
				break;
			}
			invalidate();
			return true; 
		}
	}
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			MyView myview = new MyView(MainActivity.this);
			setContentView(myview);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
		<ImageView
			android:id="@+id/Iv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"/>
	</LinearLayout>
//登录和注册页面的ViewFlipper效果 
	public class MainActivity extends Activity implements OnGestureListener {
		private ViewFlipper flipper;
		private GestureDetector detector;

		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			detector = new GestureDetector(this);
			flipper = (ViewFlipper) this.findViewById(R.id.ViewFlipper01);
		}
		@Override
		public boolean onTouchEvent(MotionEvent event) {
			return this.detector.onTouchEvent(event);
		}
		@Override
		public boolean onDown(MotionEvent e) {
			return false;
		}
		@Override
		public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
				float velocityY) {
			if (e1.getX() > e2.getX()) {
				this.flipper.showNext();
			} else if (e1.getX() < e2.getX()) {
				this.flipper.showPrevious();
			} else {
				return false;
			}
			return true;
		}
		@Override
		public void onLongPress(MotionEvent e) {
		}
		@Override
		public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
				float distanceY) {
			return false;
		}
		@Override
		public boolean onSingleTapUp(MotionEvent e) {
			return false;
		}
		@Override
		public void onShowPress(MotionEvent e) {
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
		<ViewFlipper
			android:id="@+id/ViewFlipper01"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" >
			<LinearLayout
				android:id="@+id/LinearLayout01"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:orientation="vertical" >
				<TextView
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:textSize="20dip"
					android:text="我是第一屏" />
				<EditText 
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:hint="请输入用户名:"
					/>
				<EditText 
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:hint="请输入密码:"
					/>
				<Button 
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:text="登录"
					/>
			</LinearLayout>
			<LinearLayout
				android:id="@+id/LinearLayout02"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:orientation="vertical" >
				<TextView
					android:id="@+id/TextView02"
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:textSize="20dip"
					android:text="我是第二屏" />
				<EditText 
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:hint="请输入用户名:"
					/>
				<EditText 
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:hint="请输入密码:"
					/>
				<EditText 
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:hint="请输入邮箱:"
					/>
				<Button 
					android:layout_width="match_parent"
					android:layout_height="wrap_content"
					android:text="注册"
					/>
			</LinearLayout>
		</ViewFlipper>
	</LinearLayout>
//神庙逃亡的操作模拟效果 
	public class MainActivity extends Activity implements OnGestureListener {
		private GestureDetector detector;
		private ImageView Iv;
		private Animation amUp;
		private Animation amDown;
		private Animation amLeft;
		private Animation amRight;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			detector = new GestureDetector(this);
			Iv = (ImageView)findViewById(R.id.Iv);		
			initAnimation();
		}
		private void initAnimation() {
			int screenWidth  = getWindowManager().getDefaultDisplay().getWidth();
			int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
			Log.e("screenWidth",screenWidth+ "");
			Log.e("screenHeight",screenHeight+ "");
			amUp = new TranslateAnimation(0, 0, 0, -screenHeight/2);
			amUp. setDuration (500 );
			amUp.setRepeatCount(1);
			amUp.setRepeatMode(Animation.REVERSE);
			amDown = new TranslateAnimation(0, 0, 0, screenHeight/2);
			amDown. setDuration (500);
			amDown.setRepeatCount(1);
			amDown.setRepeatMode(Animation.REVERSE);
			amLeft = new TranslateAnimation(0, -screenWidth/2, 0, 0);
			amLeft. setDuration (500 );
			amLeft.setRepeatCount(1);
			amLeft.setRepeatMode(Animation.REVERSE);
			amRight = new TranslateAnimation(0, screenWidth/2, 0, 0);
			amRight. setDuration (500 );
			amRight.setRepeatCount(1);
			amRight.setRepeatMode(Animation.REVERSE);
		}
		@Override
		public boolean onTouchEvent(MotionEvent event) {
			return this.detector.onTouchEvent(event);
		}
		@Override
		public boolean onDown(MotionEvent e) {
			return false;
		}
		@Override
		public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
				float velocityY) {
			if (e1.getX() - e2.getX() > 100) {
				Iv.startAnimation(amLeft);
				Toast.makeText(MainActivity.this, "左", Toast.LENGTH_SHORT).show();
				return true;
			} else if (e1.getX() - e2.getX() < -100) {
				Iv.startAnimation(amRight);
				Toast.makeText(MainActivity.this, "右", Toast.LENGTH_SHORT).show();
				return true;
			} else if (e1.getY() - e2.getY() > 100) {
				Iv.startAnimation(amUp);
				Toast.makeText(MainActivity.this, "上", Toast.LENGTH_SHORT).show();
				return true;
			} else if (e1.getY() - e2.getY() < -100) {
				Iv.startAnimation(amDown);
				Toast.makeText(MainActivity.this, "下", Toast.LENGTH_SHORT).show();
				return true;
			}
			return true;
		}
		@Override
		public void onLongPress(MotionEvent e) {
		}
		@Override
		public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
				float distanceY) {
			return false;
		}
		@Override
		public boolean onSingleTapUp(MotionEvent e) {
			return false;
		}
		@Override
		public void onShowPress(MotionEvent e) {
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
   	>
		<ImageView 
			android:id="@+id/Iv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:src="@drawable/ic_launcher"
			android:scaleType="center"
			/>
	</LinearLayout>
//手势库的创建及手势识别 
	//activity_creategesture
	<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black"
    android:orientation="vertical">
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal">
			<TextView
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_marginRight="6dip"
				android:textColor="@android:color/background_light"
				android:text="@string/prompt_gesture_name"
				android:textAppearance="?android:attr/textAppearanceMedium" />
			<EditText
				android:id="@+id/gesture_name"
				android:layout_width="0dip"
				android:layout_weight="1.0"
				android:textColor="@android:color/black"
				android:layout_height="wrap_content"
				android:maxLength="40"
				android:singleLine="true" />
		</LinearLayout>
		<android.gesture.GestureOverlayView
			android:id="@+id/gestures_overlay"
			android:layout_width="match_parent"
			android:layout_height="0dip"
			android:layout_weight="1.0"
			android:gestureStrokeType="multiple" />
		<LinearLayout
			style="@android:style/ButtonBar"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal">
			<Button
				android:id="@+id/done"
				android:layout_width="0dip"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:enabled="false"
				android:onClick="addGesture"
				android:text="@string/button_done" />
			<Button
				android:layout_width="0dip"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:onClick="cancelGesture"
				android:text="@string/button_discard" />
		</LinearLayout>
	</LinearLayout>
	//activity_gestureidentify
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/black"
    android:orientation="vertical" >
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:textColor="@android:color/background_light"
			android:text="请在下面绘制手势:" />
		<android.gesture.GestureOverlayView
			android:id="@+id/gesture_overlay_view_test"
			android:layout_width="match_parent"
			android:layout_height="0dip"
			android:layout_weight="1.0"
			android:gestureStrokeType="multiple" />
	</LinearLayout>
	//activity_main
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black"
    android:orientation="vertical" >
		<ListView
			android:id="@android:id/list"
			android:layout_width="match_parent"
			android:layout_height="0dip"
			android:layout_weight="1.0" />
		<TextView
			android:id="@android:id/empty"
			android:layout_width="match_parent"
			android:layout_height="0dip"
			android:layout_weight="1.0"
			android:gravity="center"
			android:text="@string/gestures_loading"
			android:textAppearance="?android:attr/textAppearanceMedium" />
		<LinearLayout
			style="@android:style/ButtonBar"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal" >
			<Button
				android:id="@+id/addButton"
				android:layout_width="0dip"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:enabled="false"
				android:onClick="addGesture"
				android:text="@string/button_add" />
			<Button
				android:id="@+id/reloadButton"
				android:layout_width="0dip"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:enabled="false"
				android:onClick="reloadGestures"
				android:text="@string/button_reload" />
			<Button
				android:id="@+id/recognitionButton"
				android:layout_width="0dip"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:enabled="true"
				android:onClick="recognitionGestures"
				android:text="@string/button_ident" />
		</LinearLayout>
	</LinearLayout>
	//dialog_rename
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="20dip"
    android:orientation="vertical">
		<TextView
			android:id="@+id/label"
			android:layout_height="wrap_content"
			android:layout_width="wrap_content"
			android:text="@string/gestures_rename_label"
			android:gravity="left"
			android:textAppearance="?android:attr/textAppearanceMedium" />
		<EditText
			android:id="@+id/name"
			android:layout_height="wrap_content"
			android:layout_width="match_parent"
			android:scrollHorizontally="true"
			android:autoText="false"
			android:capitalize="none"
			android:gravity="fill_horizontal"
			android:textAppearance="?android:attr/textAppearanceMedium" />
	</LinearLayout>
	//gestures_item
	<TextView xmlns:android="http://schemas.android.com/apk/res/android"
		android:id="@android:id/text1"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:gravity="center_vertical"
		android:minHeight="?android:attr/listPreferredItemHeight"
		android:textColor="@android:color/background_light"
		android:drawablePadding="12dip"
		android:paddingLeft="6dip"
		android:paddingRight="6dip"
		android:ellipsize="marquee"
		android:singleLine="true"
		android:textAppearance="?android:attr/textAppearanceLarge" />
	public class CreateGestureActivity extends Activity {
		private static final float LENGTH_THRESHOLD = 120.0f;
		private Gesture mGesture;
		private View mDoneButton;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_creategesture);
			mDoneButton = findViewById(R.id.done);
			GestureOverlayView overlay = 
					(GestureOverlayView) findViewById(R.id.gestures_overlay);
			overlay.addOnGestureListener(new GesturesProcessor());
		}
		@Override
		protected void onSaveInstanceState(Bundle outState) {
			super.onSaveInstanceState(outState);
			if (mGesture != null) {
				outState.putParcelable("gesture", mGesture);
			}
		}
		@Override
		protected void onRestoreInstanceState(Bundle savedInstanceState) {
			super.onRestoreInstanceState(savedInstanceState);
			mGesture = savedInstanceState.getParcelable("gesture");
			if (mGesture != null) {
				final GestureOverlayView overlay =
						(GestureOverlayView) 
						findViewById(R.id.gestures_overlay);
				overlay.post(new Runnable() {
					public void run() {
						overlay.setGesture(mGesture);
					}
				});

				mDoneButton.setEnabled(true);
			}
		}
		@SuppressWarnings({"UnusedDeclaration"})
		public void addGesture(View v) {
			if (mGesture != null) {
				final TextView input = 
						(TextView) findViewById(R.id.gesture_name);
				final CharSequence name = input.getText();
				if (name.length() == 0) {
					input.setError(getString(R.string.error_missing_name));
					return;
				}
				final GestureLibrary store = MainActivity.getStore();
				store.addGesture(name.toString(), mGesture);
				store.save();
				setResult(RESULT_OK);
				final String path = 
						new File(Environment.getExternalStorageDirectory(),
						"gestures").getAbsolutePath();
				Toast.makeText(this, 
						getString(R.string.save_success, path), 
						Toast.LENGTH_LONG).show();
			} else {
				setResult(RESULT_CANCELED);
			}
			finish();
		}
		@SuppressWarnings({"UnusedDeclaration"})
		public void cancelGesture(View v) {
			setResult(RESULT_CANCELED);
			finish();
		}
		private class GesturesProcessor 
			implements GestureOverlayView.OnGestureListener {
			public void onGestureStarted(GestureOverlayView overlay,
					MotionEvent event) {
				mDoneButton.setEnabled(false);
				mGesture = null;
			}
			public void onGesture(GestureOverlayView overlay,
					MotionEvent event) {
			}
			public void onGestureEnded(GestureOverlayView overlay,
					MotionEvent event) {
				mGesture = overlay.getGesture();
				if (mGesture.getLength() < LENGTH_THRESHOLD) {
					overlay.clear(false);
				}
				mDoneButton.setEnabled(true);
			}
			public void onGestureCancelled(GestureOverlayView overlay,
					MotionEvent event) {
			}
		}
	}
	public class MainActivity extends ListActivity {
		private static final int STATUS_SUCCESS = 0;
		private static final int STATUS_CANCELLED = 1;
		private static final int STATUS_NO_STORAGE = 2;
		private static final int STATUS_NOT_LOADED = 3;
		private static final int MENU_ID_RENAME = 1;
		private static final int MENU_ID_REMOVE = 2;
		private static final int DIALOG_RENAME_GESTURE = 1;
		private static final int REQUEST_NEW_GESTURE = 1;
		private static final String GESTURES_INFO_ID = "gestures.info_id";
		private final File mStoreFile = new File(
				Environment.getExternalStorageDirectory(), "gestures");
		private final Comparator<NamedGesture> mSorter = new Comparator<NamedGesture>() {
			public int compare(NamedGesture object1, NamedGesture object2) {
				return object1.name.compareTo(object2.name);
			}
		};
		private static GestureLibrary sStore;
		private GesturesAdapter mAdapter;
		private GesturesLoadTask mTask;
		private TextView mEmpty;
		private Dialog mRenameDialog;
		private EditText mInput;
		private NamedGesture mCurrentRenameGesture;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			mAdapter = new GesturesAdapter(this);
			setListAdapter(mAdapter);
			if (sStore == null) {
				sStore = GestureLibraries.fromFile(mStoreFile);
			}
			mEmpty = (TextView) findViewById(android.R.id.empty);
			loadGestures();
			registerForContextMenu(getListView());
		}
		static GestureLibrary getStore() {
			return sStore;
		}
		@SuppressWarnings({ "UnusedDeclaration" })
		public void reloadGestures(View v) {
			loadGestures();
		}
		@SuppressWarnings({ "UnusedDeclaration" })
		public void addGesture(View v) {
			Intent intent = new Intent(this, CreateGestureActivity.class);
			startActivityForResult(intent, REQUEST_NEW_GESTURE);
		}
		public void recognitionGestures(View v) {
			Intent intent = new Intent(this, RecognitionGestureActivity.class);
			startActivity(intent);
		}
		@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			super.onActivityResult(requestCode, resultCode, data);
			if (resultCode == RESULT_OK) {
				switch (requestCode) {
				case REQUEST_NEW_GESTURE:
					loadGestures();
					break;
				}
			}
		}
		private void loadGestures() {
			if (mTask != null
					&& mTask.getStatus() != GesturesLoadTask.Status.FINISHED) {
				mTask.cancel(true);
			}
			mTask = (GesturesLoadTask) new GesturesLoadTask().execute();
		}
		@Override
		protected void onDestroy() {
			super.onDestroy();
			if (mTask != null
					&& mTask.getStatus() != GesturesLoadTask.Status.FINISHED) {
				mTask.cancel(true);
				mTask = null;
			}
			cleanupRenameDialog();
		}
		private void checkForEmpty() {
			if (mAdapter.getCount() == 0) {
				mEmpty.setText(R.string.gestures_empty);
			}
		}
		@Override
		protected void onSaveInstanceState(Bundle outState) {
			super.onSaveInstanceState(outState);

			if (mCurrentRenameGesture != null) {
				outState.putLong(GESTURES_INFO_ID,
						mCurrentRenameGesture.gesture.getID());
			}
		}
		@Override
		protected void onRestoreInstanceState(Bundle state) {
			super.onRestoreInstanceState(state);
			long id = state.getLong(GESTURES_INFO_ID, -1);
			if (id != -1) {
				final Set<String> entries = sStore.getGestureEntries();
				out: for (String name : entries) {
					for (Gesture gesture : sStore.getGestures(name)) {
						if (gesture.getID() == id) {
							mCurrentRenameGesture = new NamedGesture();
							mCurrentRenameGesture.name = name;
							mCurrentRenameGesture.gesture = gesture;
							break out;
						}
					}
				}
			}
		}
		@Override
		public void onCreateContextMenu(ContextMenu menu, View v,
				ContextMenu.ContextMenuInfo menuInfo) {
			super.onCreateContextMenu(menu, v, menuInfo);
			AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
			menu.setHeaderTitle(((TextView) info.targetView).getText());
			menu.add(0, MENU_ID_RENAME, 0, R.string.gestures_rename);
			menu.add(0, MENU_ID_REMOVE, 0, R.string.gestures_delete);
		}
		@Override
		public boolean onContextItemSelected(MenuItem item) {
			final AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item
					.getMenuInfo();
			final NamedGesture gesture = (NamedGesture) menuInfo.targetView
					.getTag();
			switch (item.getItemId()) {
			case MENU_ID_RENAME:
				renameGesture(gesture);
				return true;
			case MENU_ID_REMOVE:
				deleteGesture(gesture);
				return true;
			}
			return super.onContextItemSelected(item);
		}
		private void renameGesture(NamedGesture gesture) {
			mCurrentRenameGesture = gesture;
			showDialog(DIALOG_RENAME_GESTURE);
		}
		@Override
		protected Dialog onCreateDialog(int id) {
			if (id == DIALOG_RENAME_GESTURE) {
				return createRenameDialog();
			}
			return super.onCreateDialog(id);
		}
		@Override
		protected void onPrepareDialog(int id, Dialog dialog) {
			super.onPrepareDialog(id, dialog);
			if (id == DIALOG_RENAME_GESTURE) {
				mInput.setText(mCurrentRenameGesture.name);
			}
		}
		private Dialog createRenameDialog() {
			final View layout = View.inflate(this, R.layout.dialog_rename, null);
			mInput = (EditText) layout.findViewById(R.id.name);
			((TextView) layout.findViewById(R.id.label))
					.setText(R.string.gestures_rename_label);
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setIcon(0);
			builder.setTitle(getString(R.string.gestures_rename_title));
			builder.setCancelable(true);
			builder.setOnCancelListener(new Dialog.OnCancelListener() {
				public void onCancel(DialogInterface dialog) {
					cleanupRenameDialog();
				}
			});
			builder.setNegativeButton(getString(R.string.cancel_action),
					new Dialog.OnClickListener() {
						public void onClick(DialogInterface dialog, int which) {
							cleanupRenameDialog();
						}
					});
			builder.setPositiveButton(getString(R.string.rename_action),
					new Dialog.OnClickListener() {
						public void onClick(DialogInterface dialog, int which) {
							changeGestureName();
						}
					});
			builder.setView(layout);
			return builder.create();
		}
		private void changeGestureName() {
			final String name = mInput.getText().toString();
			if (!TextUtils.isEmpty(name)) {
				final NamedGesture renameGesture = mCurrentRenameGesture;
				final GesturesAdapter adapter = mAdapter;
				final int count = adapter.getCount();
				for (int i = 0; i < count; i++) {
					final NamedGesture gesture = adapter.getItem(i);
					if (gesture.gesture.getID() == renameGesture.gesture.getID()) {
						sStore.removeGesture(gesture.name, gesture.gesture);
						gesture.name = mInput.getText().toString();
						sStore.addGesture(gesture.name, gesture.gesture);
						break;
					}
				}
				adapter.notifyDataSetChanged();
			}
			mCurrentRenameGesture = null;
		}
		private void cleanupRenameDialog() {
			if (mRenameDialog != null) {
				mRenameDialog.dismiss();
				mRenameDialog = null;
			}
			mCurrentRenameGesture = null;
		}
		private void deleteGesture(NamedGesture gesture) {
			sStore.removeGesture(gesture.name, gesture.gesture);
			sStore.save();
			final GesturesAdapter adapter = mAdapter;
			adapter.setNotifyOnChange(false);
			adapter.remove(gesture);
			adapter.sort(mSorter);
			checkForEmpty();
			adapter.notifyDataSetChanged();
			Toast.makeText(this, R.string.gestures_delete_success,
					Toast.LENGTH_SHORT).show();
		}
		private class GesturesLoadTask extends
				AsyncTask<Void, NamedGesture, Integer> {
			private int mThumbnailSize;
			private int mThumbnailInset;
			private int mPathColor;
			@Override
			protected void onPreExecute() {
				super.onPreExecute();
				final Resources resources = getResources();
				mPathColor = resources.getColor(R.color.gesture_color);
				mThumbnailInset = (int) resources
						.getDimension(R.dimen.gesture_thumbnail_inset);
				mThumbnailSize = (int) resources
						.getDimension(R.dimen.gesture_thumbnail_size);
				findViewById(R.id.addButton).setEnabled(false);
				findViewById(R.id.reloadButton).setEnabled(false);

				mAdapter.setNotifyOnChange(false);
				mAdapter.clear();
			}
			@Override
			protected Integer doInBackground(Void... params) {
				if (isCancelled())
					return STATUS_CANCELLED;
				if (!Environment.MEDIA_MOUNTED.equals(Environment
						.getExternalStorageState())) {
					return STATUS_NO_STORAGE;
				}
				final GestureLibrary store = sStore;
				if (store.load()) {
					for (String name : store.getGestureEntries()) {
						if (isCancelled())
							break;
						for (Gesture gesture : store.getGestures(name)) {
							final Bitmap bitmap = gesture.toBitmap(mThumbnailSize,
									mThumbnailSize, mThumbnailInset, mPathColor);
							final NamedGesture namedGesture = new NamedGesture();
							namedGesture.gesture = gesture;
							namedGesture.name = name;
							mAdapter.addBitmap(namedGesture.gesture.getID(), bitmap);
							publishProgress(namedGesture);
						}
					}
					return STATUS_SUCCESS;
				}
				return STATUS_NOT_LOADED;
			}
			@Override
			protected void onProgressUpdate(NamedGesture... values) {
				super.onProgressUpdate(values);
				final GesturesAdapter adapter = mAdapter;
				adapter.setNotifyOnChange(false);
				for (NamedGesture gesture : values) {
					adapter.add(gesture);
				}
				adapter.sort(mSorter);
				adapter.notifyDataSetChanged();
			}
			@Override
			protected void onPostExecute(Integer result) {
				super.onPostExecute(result);
				if (result == STATUS_NO_STORAGE) {
					getListView().setVisibility(View.GONE);
					mEmpty.setVisibility(View.VISIBLE);
					mEmpty.setText(getString(R.string.gestures_error_loading,
							mStoreFile.getAbsolutePath()));
				} else {
					findViewById(R.id.addButton).setEnabled(true);
					findViewById(R.id.reloadButton).setEnabled(true);
					checkForEmpty();
				}
			}
		}
		static class NamedGesture {
			String name;
			Gesture gesture;
		}
		private class GesturesAdapter extends ArrayAdapter<NamedGesture> {
			private final LayoutInflater mInflater;
			private final Map<Long, Drawable> mThumbnails = Collections
					.synchronizedMap(new HashMap<Long, Drawable>());

			public GesturesAdapter(Context context) {
				super(context, 0);
				mInflater = (LayoutInflater) context
						.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			}
			void addBitmap(Long id, Bitmap bitmap) {
				mThumbnails.put(id, new BitmapDrawable(bitmap));
			}
			@Override
			public View getView(int position, View convertView, ViewGroup parent) {
				if (convertView == null) {
					convertView = mInflater.inflate(R.layout.gestures_item, parent,
							false);
				}
				final NamedGesture gesture = getItem(position);
				final TextView label = (TextView) convertView;
				label.setTag(gesture);
				label.setText(gesture.name);
				label.setCompoundDrawablesWithIntrinsicBounds(
						mThumbnails.get(gesture.gesture.getID()), null, null, null);
				return convertView;
			}
		}
	}
	public class RecognitionGestureActivity extends Activity {
		GestureLibrary mGestureLib;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_gestureidentify);
			GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gesture_overlay_view_test);
			gestures.addOnGesturePerformedListener(new GestureOverlayView.OnGesturePerformedListener() {
				@Override
				public void onGesturePerformed(GestureOverlayView overlay,
						Gesture gesture) {
					ArrayList<Prediction> predictions = mGestureLib
							.recognize(gesture);
					if (predictions.size() > 0) {
						Prediction prediction = (Prediction) predictions.get(0);
						if (prediction.score > 1.0) {
							Toast.makeText(RecognitionGestureActivity.this,
									prediction.name, Toast.LENGTH_SHORT).show();
						}
					}
				}
			});
			mGestureLib = MainActivity.getStore();
		}
	}
//滑动切换Activity的背景效果 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/Ll"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/k1"
    android:orientation="vertical" >
		<EditText
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:hint="请输入用户名:" />
		<EditText
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:hint="请输入密码:" />
		<Button 
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="登录"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private LinearLayout Ll;
		private GestureDetector gestureDetector;
		private int[] ResId = new int[]{
			R.drawable.k1,
			R.drawable.k2,
			R.drawable.k3
		};
		private int count = 0;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);

			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			gestureDetector = new GestureDetector(MainActivity.this,
					onGestureListener);
		}
		@Override
		public boolean onTouchEvent(MotionEvent event) {
			return gestureDetector.onTouchEvent(event);
		}
		private void findView() {
			Ll = (LinearLayout) findViewById(R.id.Ll);
		}
		private GestureDetector.OnGestureListener onGestureListener = new GestureDetector.SimpleOnGestureListener() {
			@Override
			public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
					float velocityY) {
				float x = e2.getX() - e1.getX();
				float y = e2.getY() - e1.getY();
				if (x > 0) {
					count++;
					count %= 3;
				} else if (x < 0) {
					count--;
					count = (count + 3) % 3;
				}
				changeImg();
				return true;
			}
		};
		public void changeImg() {
			Ll.setBackgroundResource(ResId[count]);
		}
	}
//按钮控制小人儿移动 
	public class MainActivity extends Activity {
		private Button rightButton;
		private Button leftButton;
		private Button downButton;
		private Button upButton;
		private MyViewGroup myviewgroup;

		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
			int width = wm.getDefaultDisplay().getWidth();
			int height = wm.getDefaultDisplay().getHeight();
			myviewgroup = (MyViewGroup) findViewById(R.id.mygroupview);
			TextView textView = new TextView(this);
			textView.setWidth(80);
			textView.setHeight(80);
			textView.setLayoutParams(new LayoutParams(80, 80));
			textView.setBackgroundResource(R.drawable.ic_launcher);
			myviewgroup.setGravity(Gravity.CENTER);
			myviewgroup.addView(textView);
			findView();
			setListener();
		}
		private void setListener() {
			rightButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					myviewgroup.scrollToRight();
				}
			});
			leftButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					myviewgroup.scrollToLeft();
				}
			});
			downButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					myviewgroup.scrollToDown();
				}
			});
			upButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					myviewgroup.scrollToUp();
				}
			});
		}
		private void findView() {
			rightButton = (Button) findViewById(R.id.BtnRight);
			leftButton = (Button) findViewById(R.id.BtnLeft);
			downButton = (Button) findViewById(R.id.BtnDown);
			upButton = (Button) findViewById(R.id.BtnUp);
		}
	}
	public class MyViewGroup extends LinearLayout {
		private Scroller mScroller;
		private int space = 10;
		public MyViewGroup(Context context) {
			super(context);
			initCustomLinearLayout(context);
		}
		public MyViewGroup(Context context, AttributeSet attrs) {
			super(context, attrs);
			initCustomLinearLayout(context);
		}
		public void scrollToRight() {
			mScroller.startScroll(mScroller.getCurrX(),mScroller.getCurrY(),
					-space,0, 250);
			invalidate();
		}
		public void scrollToUp() {
			mScroller.startScroll(mScroller.getCurrX(),mScroller.getCurrY(),
					0, space, 250);
			invalidate();
		}
		public void scrollToDown() {
			mScroller.startScroll(mScroller.getCurrX(),mScroller.getCurrY(),
					0, -space, 250);
			invalidate();
		}
		
		public void scrollToLeft() {
			mScroller.startScroll(mScroller.getCurrX(),mScroller.getCurrY(),
					space, 0,250);
			invalidate();
		}
		@Override
		public void onLayout(boolean changed, int left, int top, int right, int bottom) {
			super.onLayout(changed, left, top, right, bottom);
		}
		
		@Override
		public void computeScroll() {
			if (!mScroller.isFinished()) {
				if (mScroller.computeScrollOffset()) {
					scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
					invalidate();
				}
			}
		}
		private void initCustomLinearLayout(Context context) {
			mScroller = new Scroller(context);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="@color/skyblue">
		<com.wyl.example.MyViewGroup
			android:id="@+id/mygroupview"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:layout_weight="1" />
		<LinearLayout
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:orientation="horizontal" 
			android:layout_gravity="center_horizontal">
			<Button
				android:id="@+id/BtnLeft"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:text="@string/left_button" />
			<Button
				android:id="@+id/BtnRight"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:text="@string/right_button" />
		</LinearLayout>
		<LinearLayout
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:orientation="horizontal" 
			android:layout_gravity="center_horizontal">
			<Button
				android:id="@+id/BtnUp"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:text="@string/up_button" />
			<Button
				android:id="@+id/BtnDown"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:text="@string/down_button" />
		</LinearLayout>
	</LinearLayout>
//Android中多线程处理 
	
//异步请求广告图片 
	<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<LinearLayout
			android:id="@+id/layout"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:layout_gravity="center_horizontal"
			android:background="@color/skyblue"
			android:orientation="vertical" >
			<ImageView
				android:id="@+id/Iv1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content" />
			<ImageView
				android:id="@+id/Iv2"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content" />
			<ImageView
				android:id="@+id/Iv3"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content" />
		</LinearLayout>
	</ScrollView>
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			ImageHandle imgHandle1 =new ImageHandle(this);  
			imgHandle1.loadImg("http://www.baidu.com/img/baidu_logo.gif", R.id.Iv1); 
			ImageHandle imgHandle2 =new ImageHandle(this);  
			imgHandle2.loadImg("http://www.baidu.com/img/baidu_logo.gif", R.id.Iv2); 
			ImageHandle imgHandle3 =new ImageHandle(this);  
			imgHandle3.loadImg("http://www.baidu.com/img/baidu_logo.gif", R.id.Iv3); 
		}
	}
	public class ImageHandle extends Handler{
		Activity context;
		public ImageHandle(Activity context){
			this.context=context;
		}
		@Override
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			ImageView img=(ImageView)context.findViewById(msg.arg1);
			img.setImageDrawable((Drawable)msg.obj);
		}
		public void loadImg(final String imgUrl,final int viewId){
			Thread thread=new Thread(){
				@Override
				public void run() {
					try {
						Drawable drawable=Drawable.createFromStream(new URL(imgUrl).openStream(), "img.png");
						Message msg=ImageHandle.this.obtainMessage();
						msg.arg1=viewId;
						msg.obj=drawable;
						ImageHandle.this.sendMessage(msg);
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			};
			thread.start();
			thread=null;
		}
	}
//本地三国演义文本的异步加载 
	<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<LinearLayout
			android:id="@+id/layout"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:layout_gravity="center_horizontal"
			android:background="@color/skyblue"
			android:orientation="vertical" >
			<TextView
				android:id="@+id/Tv"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content" />
		</LinearLayout>
	</ScrollView>
	public class FileRead {
		public boolean readfinish = false;
		public List<String> list = null;
		public class ReadFileThread extends Thread {
			public void run() {
				list = new ArrayList<String>(100);
				list.clear();
				readfinish = false;
				try {
					RandomAccessFile raf = new RandomAccessFile("/sdcard/sanguo.txt",
							"r");
					while (raf.getFilePointer() < raf.length()) {
						list.add(new String(raf.readLine().getBytes("iso8859-1"),"utf-8"));
					}
				} catch (Exception e1) {
					e1.printStackTrace();
				}
				readfinish = true;
			}
		};
	}
	public class MainActivity extends Activity {
		FileRead fr = null;
		Handler mHandler = null;
		int curi = 0;
		Runnable updateui = null;
		String[] tmp = null;
		String s = "";
		TextView tv = null;
		class ReadListener extends Thread {
			public void run() {
				int i = 0, newi = 0;
				while (!fr.readfinish) {
					newi = fr.list.size();
					if ((newi - i) > 10)
					{
						i = newi;
						tmp = (String[]) fr.list.toArray(new String[fr.list.size()]);
						mHandler.post(updateui);
					}
				}
				tmp = (String[]) fr.list.toArray(new String[fr.list.size()]);
				mHandler.post(updateui);
			}
		};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			tv = (TextView) findViewById(R.id.Tv);
			fr = new FileRead();
			ReadFileThread readThread = fr.new ReadFileThread();
			updateui = new Runnable()
			{
				@Override
				public void run() {
					int i = 0;
					for (i = curi; i < tmp.length; i++) {
						s += tmp[i] + "\n";
					}
					tv.setText(s);
					curi = i;
				}
			};
			readThread.start();
			ReadListener updateThread = new ReadListener();
			mHandler = new Handler();
			updateThread.start();
		}
	}
//应用程序的启动动画 
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			new Handler().postDelayed(new Runnable(){   
							public void run() {   
								Intent i = new Intent(MainActivity.this, NextActivity.class);    
								MainActivity.this.startActivity(i);   
								MainActivity.this.finish();    
							}   
						}, 3000);	
		}
	}
	public class NextActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_next);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center_horizontal"
    android:orientation="vertical" >
		<ImageView
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:scaleType="fitXY"
			android:src="@drawable/baidu" />
	</LinearLayout>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center_horizontal"
    android:orientation="vertical" >
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="I am NextActivity!" />
	</LinearLayout>
//NBA球星信息介绍的网格视图 
	public class AsyncImageLoader
		{
			private HashMap<String, SoftReference<Drawable>> imageCache;

			public AsyncImageLoader()
			{
				imageCache = new HashMap<String, SoftReference<Drawable>>();
			}
			public Drawable loadDrawable(final String imageUrl,
					final ImageCallback imageCallback)
			{
				if (imageCache.containsKey(imageUrl))
				{
					SoftReference<Drawable> softReference = imageCache.get(imageUrl);
					Drawable drawable = softReference.get();
					if (drawable != null)
					{
						return drawable;
					}
				}
				final Handler handler = new Handler()
				{
					public void handleMessage(Message message)
					{
						imageCallback.imageLoaded((Drawable) message.obj, imageUrl);
					}
				};
				new Thread()
				{
					@Override
					public void run()
					{
						Drawable drawable = loadImageFromUrl(imageUrl);
						imageCache.put(imageUrl, new SoftReference<Drawable>(drawable));
						Message message = handler.obtainMessage(0, drawable);
						handler.sendMessage(message);
					}
				}.start();
				return null;
			}
			public static Drawable loadImageFromUrl(String url)
			{
				URL m;
				InputStream i = null;
				try
				{
					m = new URL(url);
					i = (InputStream) m.getContent();
				}
				catch (MalformedURLException e1)
				{
					e1.printStackTrace();
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
				Drawable d = Drawable.createFromStream(i, "src");
				return d;
			}
			public interface ImageCallback
			{
				public void imageLoaded(Drawable imageDrawable, String imageUrl);
			}
		}
	public class GirdItem {
		private String imageUrl;
		private String text;
		public GirdItem(String imageUrl, String text) {
			this.imageUrl = imageUrl;
			this.text = text;
		}
		public String getImageUrl() {
			return imageUrl;
		}
		public String getText() {
			return text;
		}
	}
	public class GridViewAdapter extends ArrayAdapter<GirdItem> {
		private GridView gridView;
		private AsyncImageLoader asyncImageLoader;
		public GridViewAdapter(Activity activity,
				List<GirdItem> imageAndTexts, GridView gridView) {
			super(activity, 0, imageAndTexts);
			this.gridView = gridView;
			asyncImageLoader = new AsyncImageLoader();
		}
		public View getView(int position, View convertView, ViewGroup parent) {
			Activity activity = (Activity) getContext();
			View rowView = convertView;
			ViewCache viewCache;
			if (rowView == null) {
				LayoutInflater inflater = activity.getLayoutInflater();
				rowView = inflater.inflate(R.layout.griditem, null);
				viewCache = new ViewCache(rowView);
				rowView.setTag(viewCache);
			} else {
				viewCache = (ViewCache) rowView.getTag();
			}
			GirdItem imageAndText = getItem(position);
			String imageUrl = imageAndText.getImageUrl();
			ImageView imageView = viewCache.getImageView();
			imageView.setTag(imageUrl);
			Drawable cachedImage = asyncImageLoader.loadDrawable(imageUrl,
					new com.wyl.example.AsyncImageLoader.ImageCallback() {
						public void imageLoaded(Drawable imageDrawable,
								String imageUrl) {
							ImageView imageViewByTag = (ImageView) gridView
									.findViewWithTag(imageUrl);
							if (imageViewByTag != null) {
								imageViewByTag.setImageDrawable(imageDrawable);
							}
						}
					});
			if (cachedImage == null) {
				imageView.setImageResource(R.drawable.ic_launcher);
			} else {
				imageView.setImageDrawable(cachedImage);
			}
			TextView textView = viewCache.getTextView();
			textView.setText(imageAndText.getText());
			return rowView;
		}
	}
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			GridView gridView = (GridView) findViewById(R.id.Gv);
			List<GirdItem> list = new ArrayList<GirdItem>();
			list.add(new GirdItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/4244.jpg",
					"杜兰特"));
			list.add(new GirdItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/4390.jpg",
					"维斯布鲁克"));
			list.add(new GirdItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/3843.jpg",
					"马丁"));
			list.add(new GirdItem("http://www.sinaimg.cn/ty/nba/players/2008/4486.jpg",
					"依巴卡"));
			list.add(new GirdItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/4563.jpg",
					"哈登"));
			list.add(new GirdItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/4795.jpg",
					"JimLin"));
			list.add(new GirdItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/4920.jpg",
					"帕森斯"));
			gridView.setAdapter(new GridViewAdapter(this, list, gridView));
		}
	}
	public class ViewCache{
		private View baseView;
		private TextView textView;
		private ImageView imageView;
		public ViewCache(View baseView)
		{
			this.baseView = baseView;
		}
		public TextView getTextView()
		{
			if (textView == null)
			{
				textView = (TextView) baseView.findViewById(R.id.ItemTv);
			}
			return textView;
		}
		public ImageView getImageView()
		{
			if (imageView == null)
			{
				imageView = (ImageView) baseView.findViewById(R.id.ItemIv);
			}
			return imageView;
		}
	}
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >
		<GridView
			android:id="@+id/Gv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:columnWidth="70dp"
			android:gravity="center"
			android:horizontalSpacing="10dp"
			android:numColumns="2"
			android:stretchMode="columnWidth"
			android:verticalSpacing="10dp" />
	</RelativeLayout>
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="4dip" >
		<ImageView
			android:id="@+id/ItemIv"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_centerHorizontal="true" >
		</ImageView>
		<TextView
			android:id="@+id/ItemTv"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_below="@+id/ItemIv"
			android:layout_centerHorizontal="true" >
		</TextView>
	</RelativeLayout>
//NBA球星信息介绍的列表视图 
	public class AsyncImageLoader{
		private HashMap<String, SoftReference<Drawable>> imageCache;
		public AsyncImageLoader()
		{
			imageCache = new HashMap<String, SoftReference<Drawable>>();
		}
		public Drawable loadDrawable(final String imageUrl,
				final ImageCallback imageCallback)
		{
			if (imageCache.containsKey(imageUrl))
			{
				SoftReference<Drawable> softReference = imageCache.get(imageUrl);
				Drawable drawable = softReference.get();
				if (drawable != null)
				{
					return drawable;
				}
			}
			final Handler handler = new Handler()
			{
				public void handleMessage(Message message)
				{
					imageCallback.imageLoaded((Drawable) message.obj, imageUrl);
				}
			};
			new Thread()
			{
				@Override
				public void run()
				{
					Drawable drawable = loadImageFromUrl(imageUrl);
					imageCache.put(imageUrl, new SoftReference<Drawable>(drawable));
					Message message = handler.obtainMessage(0, drawable);
					handler.sendMessage(message);
				}
			}.start();
			return null;
		}
		public static Drawable loadImageFromUrl(String url)
		{
			URL m;
			InputStream i = null;
			try
			{
				m = new URL(url);
				i = (InputStream) m.getContent();
			}
			catch (MalformedURLException e1)
			{
				e1.printStackTrace();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			Drawable d = Drawable.createFromStream(i, "src");
			return d;
		}
		public interface ImageCallback
		{
			public void imageLoaded(Drawable imageDrawable, String imageUrl);
		}
	}
	public class ListItem {
		private String imageUrl;
		private String name;
		private String info;
		public ListItem(String imageUrl, String namestr,String infostr) {
			this.imageUrl = imageUrl;
			this.name = namestr;
			this.info = infostr;
		}
		public String getImageUrl() {
			return imageUrl;
		}
		public String getinfo() {
			return info;
		}
		public String getName() {
			return name;
		}
	}
	public class ListViewAdapter extends ArrayAdapter<ListItem> {
		private ListView listview;
		private AsyncImageLoader asyncImageLoader;
		public ListViewAdapter(Activity activity,
				List<ListItem> imageAndTexts, ListView listView) {
			super(activity, 0, imageAndTexts);
			this.listview = listView;
			asyncImageLoader = new AsyncImageLoader();
		}
		public View getView(int position, View convertView, ViewGroup parent) {
			Activity activity = (Activity) getContext();
			View rowView = convertView;
			ViewCache viewCache;
			if (rowView == null) {
				LayoutInflater inflater = activity.getLayoutInflater();
				rowView = inflater.inflate(R.layout.listviewitem, null);
				viewCache = new ViewCache(rowView);
				rowView.setTag(viewCache);
			} else {
				viewCache = (ViewCache) rowView.getTag();
			}
			ListItem imageAndText = getItem(position);
			String imageUrl = imageAndText.getImageUrl();
			ImageView imageView = viewCache.getImageView();
			imageView.setTag(imageUrl);
			Drawable cachedImage = asyncImageLoader.loadDrawable(imageUrl,
					new com.wyl.example.AsyncImageLoader.ImageCallback() {
						public void imageLoaded(Drawable imageDrawable,
								String imageUrl) {
							ImageView imageViewByTag = (ImageView) listview
									.findViewWithTag(imageUrl);
							if (imageViewByTag != null) {
								imageViewByTag.setImageDrawable(imageDrawable);
							}
						}
					});
			if (cachedImage == null) {
				imageView.setImageResource(R.drawable.ic_launcher);
			} else {
				imageView.setImageDrawable(cachedImage);
			}
			TextView textViewname = viewCache.getnameTextView();
			textViewname.setText(imageAndText.getName());
			TextView textViewinfo = viewCache.getinfoTextView();
			textViewinfo.setText(imageAndText.getinfo());
			return rowView;
		}
	}
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			ListView listview = (ListView) findViewById(R.id.Lv);
			List<ListItem> list = new ArrayList<ListItem>();
			list.add(new ListItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/4244.jpg",
					"杜兰特","凯文·杜兰特,小前锋,效力于俄克拉荷马雷霆队。2009-2010赛季荣膺NBA常规赛得分王,并成为NBA历史上最年轻的得分王。2009-2012赛季连续三届常规赛得分王,场均得分30.1分、27.7分、28.0分,成为最年轻的得分王与最年轻的连续两届、三届得分王。"));
			list.add(new ListItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/4390.jpg",
					"维斯布鲁克","拉塞尔·威斯布鲁克(控球后卫,效力于NBA俄克拉荷马雷霆队。2010-2011赛季入选NBA最佳第二阵容,2011-2012赛季连续第二次入选西部全明星替补阵容,2011-2012赛季助雷霆获西部冠军,打入总决赛。"));
			list.add(new ListItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/3843.jpg",
					"马丁","凯文·马丁(1983年2月1日—)出生于美国俄亥俄州曾斯维尔(Zanesville, OH),美国职业篮球运动员,司职得分后卫,效力于NBA俄克拉荷马雷霆队。"));
			list.add(new ListItem("http://www.sinaimg.cn/ty/nba/players/2008/4486.jpg",
					"依巴卡","司职大前锋,拥有极强的身体素质,擅长冲抢前场篮板,有出色的封盖能力,有一定的中距离投篮能力。"));
			list.add(new ListItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/4563.jpg",
					"哈登","詹姆斯·哈登(1989年8月26日—)出生于美国加利福尼亚州洛杉矶,美国职业篮球运动员,司职得分后卫,效力于NBA休斯顿火箭队。他是2009年NBA选秀探花,2012年入选梦十队获得奥运金牌,2013年入选NBA全明星。"));
			list.add(new ListItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/4795.jpg",
					"JimLin","林书豪(控球后卫,效力于NBA休斯敦火箭队。首位进入NBA的美籍华裔球员。2011年12月,先后被勇士队、休斯顿火箭队裁掉。2011年12月27日,他签约纽约尼克斯队。2012年夏天,林书豪与休斯敦火箭签定了一份三年的合同。"));
			list.add(new ListItem(
					"http://www.sinaimg.cn/ty/nba/players/2008/4920.jpg",
					"帕森斯","钱德勒·帕森斯,小前锋/大前锋,现效力于NBA休斯敦火箭队。"));
			listview.setAdapter(new ListViewAdapter(this, list, listview));
		}
	}
	public class ViewCache{
		private View baseView;
		private TextView textViewname;
		private TextView textViewinfo;
		private ImageView imageView;
		public ViewCache(View baseView)
		{
			this.baseView = baseView;
		}
		public TextView getnameTextView()
		{
			if (textViewname == null)
			{
				textViewname = (TextView) baseView.findViewById(R.id.ItemTvName);
			}
			return textViewname;
		}
		public TextView getinfoTextView()
		{
			if (textViewinfo == null)
			{
				textViewinfo = (TextView) baseView.findViewById(R.id.ItemTvInfo);
			}
			return textViewinfo;
		}
		public ImageView getImageView()
		{
			if (imageView == null)
			{
				imageView = (ImageView) baseView.findViewById(R.id.ItemIv);
			}
			return imageView;
		}
	}
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >
		<ListView
			android:id="@+id/Lv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			/>
	</RelativeLayout>
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:paddingBottom="4dip" >
		<ImageView
			android:id="@+id/ItemIv"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true" >
		</ImageView>
		<TextView
			android:id="@+id/ItemTvName"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:layout_below="@+id/ItemIv" >
		</TextView>
		<TextView
			android:id="@+id/ItemTvInfo"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_toRightOf="@+id/ItemIv" >
		</TextView>
	</RelativeLayout>
//文件下载 
	public class MainActivity extends Activity {
		private ProgressBar pb;		
		private TextView tv;
		private Button btn;
		private EditText et;
		private int fileSize;
		private int downLoadFileSize;
		private String filename;
		private Handler handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				if (!Thread.currentThread().isInterrupted()) {
					switch (msg.what) {
					case 0:
						pb.setMax(fileSize);
					case 1:
						pb.setProgress(downLoadFileSize);
						int result = downLoadFileSize * 100 / fileSize;
						tv.setText(result + "%");
						break;
					case 2:
						Toast.makeText(MainActivity.this, 
								"文件下载完成,请在sdcard目录下查看下载文件",
								1).show();
						break;
					case -1:
						String error = msg.getData().getString("error");
						Toast.makeText(MainActivity.this, error, 1).show();
						break;
					}
				}
				super.handleMessage(msg);
			}
		};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					new Thread() {
						public void run() {
							try {
								String str = et.getText().toString();
								down_file(
										str,
										"/sdcard/");
							} catch (ClientProtocolException e) {
								e.printStackTrace();
							} catch (IOException e) {
								e.printStackTrace();
							}
						}
					}.start();
				}
			});
		}
		private void findView() {
			pb = (ProgressBar) findViewById(R.id.Pb);
			tv = (TextView) findViewById(R.id.Tv);
			btn = (Button)findViewById(R.id.Btn);
			et = (EditText)findViewById(R.id.Et);
		}
		public void down_file(String url, String path) throws IOException {
			filename = url.substring(url.lastIndexOf("/") + 1);
			URL myURL = new URL(url);
			URLConnection conn = myURL.openConnection();
			conn.connect();
			InputStream is = conn.getInputStream();
			fileSize = conn.getContentLength();// 根据响应获取文件大小
			if (fileSize <= 0)
				throw new RuntimeException("无法获知文件大小 ");
			if (is == null)
				throw new RuntimeException("stream is null");
			FileOutputStream fos = new FileOutputStream(path + filename);
			byte buf[] = new byte[1024];
			downLoadFileSize = 0;
			sendMsg(0);
			do {
				int numread = is.read(buf);
				if (numread == -1) {
					break;
				}
				fos.write(buf, 0, numread);
				downLoadFileSize += numread;
				sendMsg(1);
			} while (true);
			sendMsg(2);
			try {
				is.close();
			} catch (Exception ex) {
				Log.e("tag", "error: " + ex.getMessage(), ex);
			}
		}
		private void sendMsg(int flag) {
			Message msg = new Message();
			msg.what = flag;
			handler.sendMessage(msg);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="请输入下载地址,然后点击下载按钮:" />
		<EditText 
			android:id="@+id/Et"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="http://p1.s.hjfile.cn/thread/201207/20120718111554562_336_o.jpg"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="点击开始下载"
			/>
		<ProgressBar
			android:id="@+id/Pb"
			style="?android:attr/progressBarStyleHorizontal"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:max="100" />
	</LinearLayout>
//中断文件下载 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="请输入下载地址,然后点击下载按钮:" />
		<EditText 
			android:id="@+id/Et"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="http://p1.s.hjfile.cn/thread/201207/20120718111554562_336_o.jpg"
			/>
		<Button 
			android:id="@+id/BtnStart"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="点击开始下载"
			/>
		<Button 
			android:id="@+id/BtnStop"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="点击终止下载"
			/>
		<ProgressBar
			android:id="@+id/Pb"
			style="?android:attr/progressBarStyleHorizontal"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:max="100" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private ProgressBar pb;		
		private TextView tv;
		private Button btnstart;
		private Button btnstop;
		private EditText et;
		private int fileSize;
		private int downLoadFileSize;
		private String filename;
		private Thread thread;
		private Handler handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				if (!Thread.currentThread().isInterrupted()) {
					switch (msg.what) {
					case 0:
						pb.setMax(fileSize);
					case 1:
						pb.setProgress(downLoadFileSize);
						int result = downLoadFileSize * 100 / fileSize;
						tv.setText(result + "%");
						break;
					case 2:
						Toast.makeText(MainActivity.this, 
								"文件下载完成,请在sdcard目录下查看下载文件",
								1).show();
						break;
					case 3:
						Toast.makeText(MainActivity.this, 
								"文件下载终止",
								1).show();
						pb.setProgress(0);
						tv.setText("0%");
						break;
					case -1:
						String error = msg.getData().getString("error");
						Toast.makeText(MainActivity.this, error, 1).show();
						break;
					}
				}
				super.handleMessage(msg);
			}
		};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btnstart.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					thread = new Thread() {
						public void run() {
							try {
								String str = et.getText().toString();
								down_file(
										str,
										"/sdcard/");
							} catch (ClientProtocolException e) {
								e.printStackTrace();
							} catch (IOException e) {
								e.printStackTrace();
							}
						}
					};
					thread.start();
				}
			});
			btnstop.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					thread.interrupt();
				}
			});
		}
		private void findView() {
			pb = (ProgressBar) findViewById(R.id.Pb);
			tv = (TextView) findViewById(R.id.Tv);
			btnstart = (Button)findViewById(R.id.BtnStart);
			btnstop = (Button)findViewById(R.id.BtnStop);
			et = (EditText)findViewById(R.id.Et);
		}
		public void down_file(String url, String path) throws IOException {
			filename = url.substring(url.lastIndexOf("/") + 1);
			URL myURL = new URL(url);
			URLConnection conn = myURL.openConnection();
			conn.connect();
			InputStream is = conn.getInputStream();
			fileSize = conn.getContentLength();
			if (fileSize <= 0)
				throw new RuntimeException("无法获知文件大小 ");
			if (is == null)
				throw new RuntimeException("stream is null");
			FileOutputStream fos = new FileOutputStream(path + filename);
			byte buf[] = new byte[1024];
			downLoadFileSize = 0;
			sendMsg(0);
			do {
				int numread = is.read(buf);
				if (Thread.currentThread().isInterrupted()) {
					sendMsg(3);
					try {
						is.close();
					} catch (Exception ex) {
						Log.e("tag", "error: " + ex.getMessage(), ex);
					}
					return;
				}
				if (numread == -1) {
					break;
				}
				fos.write(buf, 0, numread);
				downLoadFileSize += numread;
				sendMsg(1);
			} while (true);
			sendMsg(2);
			try {
				is.close();
			} catch (Exception ex) {
				Log.e("tag", "error: " + ex.getMessage(), ex);
			}

		}
		private void sendMsg(int flag) {
			Message msg = new Message();
			msg.what = flag;
			handler.sendMessage(msg);
		}
	}
//线程间通讯 
	public class MainActivity extends Activity {
		private TextView tv;
		private Handler handler = new Handler(){
			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);
				String t = tv.getText().toString();
				tv.setText(t+"\n"+msg.obj);
			}
		};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			
			setContentView(R.layout.activity_main);
			tv = (TextView)findViewById(R.id.Tv);
			new Thread(){
				@Override
				public void run() {
					super.run();
					int i = 0;
					String time;
					SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
					while(i++ < 20){
						time = df.format(new Date());
						Log.e("Thread---The Thread id is :"
							,Thread.currentThread().getId()+"");
						Log.e("Thread---Time:",time);
						Message message=new Message();
						message.obj = time;
						handler.sendMessage(message);
						try {
							sleep(2000);
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
					}
				}
			}.start();
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="接受来自子线程的消息如下:" />
	</LinearLayout>
//本地图片加载速度测试器 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<ImageView
			android:id="@+id/Iv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:src="@drawable/baidu"/>
		<Button
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击开始循环加载图片"/>
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="接受来自子线程的消息如下:\n" />
	</LinearLayout>
	public class MainActivity extends Activity {
		public final static int LOAD_PROGRESS = 0;
		public final static int LOAD_COMPLETE = 1;
		Button btn = null;
		TextView tv = null;
		Long mLoadStatr = 0L;
		Long mLoadEnd = 0L;
		Handler handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				switch (msg.what) {
				case LOAD_PROGRESS:
					tv.setText(tv.getText()+"时间:"+msg.arg2+"\t当前读取到第" + msg.arg1 + "张图片\n");
					break;
				case LOAD_COMPLETE:
					tv.setText("读取结束一共耗时" + msg.arg1 + "毫秒\t平均读取时间:"+msg.arg2+"毫秒\n");
					break;
				}
				super.handleMessage(msg);
			}
		};
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					LoadImage();
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			tv = (TextView) findViewById(R.id.Tv);
			tv.setText("点击按钮开始测试加载图片的速度:\n");
		}
		public void LoadImage() {
			new Thread() {
				@Override
				public void run() {
					mLoadStatr = System.currentTimeMillis();
					for (int i = 0; i < 100; i++) {
						ReadPic(MainActivity.this, R.drawable.baidu);
						Message msg = new Message();
						msg.what = LOAD_PROGRESS;
						msg.arg1 = i + 1;
						msg.arg2 = (int) System.currentTimeMillis();
						handler.sendMessage(msg);
					}
					mLoadEnd = System.currentTimeMillis();
					Message msg = new Message();
					msg.what = LOAD_COMPLETE;
					msg.arg1 = (int) (mLoadEnd - mLoadStatr);
					msg.arg2 = msg.arg1/100;
					handler.sendMessage(msg);
				}
			}.start();
		}
		public Bitmap ReadPic(Context context, int resId) {
			BitmapFactory.Options opt = new BitmapFactory.Options();
			opt.inPreferredConfig = Bitmap.Config.RGB_565;
			opt.inPurgeable = true;
			opt.inInputShareable = true;
			InputStream is = context.getResources().openRawResource(resId);
			return BitmapFactory.decodeStream(is, null, opt);
		}
	}
//Surface的读写刷新 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:background="@android:color/black" >
			<Button
				android:id="@+id/Btn1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:background="@android:color/white"
				android:layout_weight="1"
				android:text="单个独立线程" >
			</Button>
			<Button
				android:id="@+id/Btn2"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:background="@android:color/white"
				android:layout_weight="1"
				android:text="两个独立线程" >
			</Button>
		</LinearLayout>
		<SurfaceView
			android:id="@+id/Sv"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent" >
		</SurfaceView>
	</LinearLayout>
	public class MainActivity extends Activity {
		Button btnSingleThread;
		Button btnDoubleThread;
		SurfaceView sfv;
		SurfaceHolder sfh;
		ArrayList<Integer> imgList = new ArrayList<Integer>();
		int imgWidth, imgHeight;
		Bitmap bitmap;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btnSingleThread.setOnClickListener(new myOnClickListener());
			btnDoubleThread.setOnClickListener(new myOnClickListener());
			sfh.addCallback(new MyCallBack());
		}
		private void findView() {
			btnSingleThread = (Button) this.findViewById(R.id.Btn1);
			btnDoubleThread = (Button) this.findViewById(R.id.Btn2);
			sfv = (SurfaceView) this.findViewById(R.id.Sv);
			sfh = sfv.getHolder();
		}
		class myOnClickListener implements View.OnClickListener {
			@Override
			public void onClick(View v) {
				if (v == btnSingleThread) {
					new Load_DrawImage(0, 0).start();
				} else if (v == btnDoubleThread) {
					new LoadImage().start();
					new DrawImage(imgWidth + 10, 0).start();
				}
			}
		}
		class MyCallBack implements SurfaceHolder.Callback {
			@Override
			public void surfaceChanged(SurfaceHolder holder, int format, int width,
					int height) {
				Log.i("Surface:", "Change");

			}
			@Override
			public void surfaceCreated(SurfaceHolder holder) {
				Log.i("Surface:", "Create");
				Field[] fields = R.drawable.class.getDeclaredFields();
				for (Field field : fields) {
					if (!"ic_launcher".equals(field.getName()))
					{
						int index = 0;
						try {
							index = field.getInt(R.drawable.class);
						} catch (IllegalArgumentException e) {
							e.printStackTrace();
						} catch (IllegalAccessException e) {
							e.printStackTrace();
						}
						imgList.add(index);
					}
				}
				Bitmap bmImg = BitmapFactory.decodeResource(getResources(),
						imgList.get(0));
				imgWidth = bmImg.getWidth();
				imgHeight = bmImg.getHeight();
			}
			@Override
			public void surfaceDestroyed(SurfaceHolder holder) {
				Log.i("Surface:", "Destroy");
			}
		}
		class Load_DrawImage extends Thread {
			int x, y;
			int imgIndex = 0;
			public Load_DrawImage(int x, int y) {
				this.x = x;
				this.y = y;
			}
			public void run() {
				while (true) {
					Canvas c = sfh.lockCanvas(new Rect(this.x, this.y, this.x
							+ imgWidth, this.y + imgHeight));
					Bitmap bmImg = BitmapFactory.decodeResource(getResources(),
							imgList.get(imgIndex));
					c.drawBitmap(bmImg, this.x, this.y, new Paint());
					imgIndex++;
					if (imgIndex == imgList.size())
						imgIndex = 0;
					sfh.unlockCanvasAndPost(c);
				}
			}
		};
		class DrawImage extends Thread {
			int x, y;
			public DrawImage(int x, int y) {
				this.x = x;
				this.y = y;
			}
			public void run() {
				while (true) {
					if (bitmap != null) {
						Canvas c = sfh.lockCanvas(new Rect(this.x, this.y, this.x
								+ imgWidth, this.y + imgHeight));
						c.drawBitmap(bitmap, this.x, this.y, new Paint());
						sfh.unlockCanvasAndPost(c);
					}
				}
			}
		};
		class LoadImage extends Thread {
			int imgIndex = 0;
			public void run() {
				while (true) {
					bitmap = BitmapFactory.decodeResource(getResources(),
							imgList.get(imgIndex));
					imgIndex++;
					if (imgIndex == imgList.size())
						imgIndex = 0;
				}
			}
		};
	}
//按两次物理返回键退出程序 
	public class MainActivity extends Activity {
		private boolean isExit=false;
		private Handler mHandler = new Handler(){
			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);
				isExit=false;
			}
		};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
		}
		@Override
		public boolean onKeyDown(int keyCode, KeyEvent event) {
			if(keyCode == KeyEvent.KEYCODE_BACK){
				if(!isExit){
					isExit=true;
					Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
					mHandler.sendEmptyMessageDelayed(0, 2000);
				}
				else{
					finish();
					System.exit(0);
				}
			}
			return false;
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:text="在2秒内点击两次返回键,可退出程序....." />
	</LinearLayout>
//线程嵌套 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:text="请查看LogCat中的子线程创建情况....." />
	</LinearLayout>
	public class MainActivity extends Activity{
		private Handler mainhandler;
		private Thread thread;
		private Thread th;
		private boolean FLAG_RUN = true;
		private int i = 0;
		private int j = 0;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			mainhandler = new Handler(cb);
			thread = new Thread(r);
			thread.start();
		}
		Runnable r = new Runnable(){
			@Override
			public void run() {
				while (FLAG_RUN) {
					i++;
					Log.e("TAG","我是子线程" + i);
					childThread();
					try {
						thread.sleep(4000);
						mainhandler.obtainMessage(1).sendToTarget();
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			}
		};
		Callback cb = new Callback(){
			@Override
			public boolean handleMessage(Message msg) {
				if (msg.what == 1) {
					if (i < 2) {
						Toast.makeText(MainActivity.this, "子线程"+i+"创建成功", Toast.LENGTH_SHORT).show();
						FLAG_RUN = true;
					} else {
						FLAG_RUN = false;
					}
				}
				return true;
			}
		};
		private void childThread() {
			j = 0;
			th = new Thread() {
				@Override
				public void run() {				
					while (true) {		
						if (j >= 3) {			
							break;
						} else {
							j++;
							Log.e("TAG","我是子线程的子线程" + j);
							try {
								th.sleep(1000);
							} catch (InterruptedException e) {
								e.printStackTrace();
							}
						}
						
					}
				}
			};
			th.start();
		}
	}
//异步任务加载网络图片 
	public class ImageAsynTask extends AsyncTask<Void, Void, Drawable> {
		private ImageView m;
		private String imageurl;
		public ImageAsynTask(ImageView i,String t){
			m = i;
			imageurl = t;
		}
		@Override
		protected Drawable doInBackground(Void... params) {
			return loadImages(imageurl);
		}
		@Override
		protected void onPostExecute(Drawable result) {
			super.onPostExecute(result);
			if (null != result) {
				m.setImageDrawable(result);
			}
			else{
				m.setImageResource(R.drawable.failed);
			}
		}
		@Override
		protected void onPreExecute() {
			super.onPreExecute();
		}
		public Drawable loadImages(String url) {
			try {
				return Drawable.createFromStream(
						(InputStream) (new URL(url)).openStream(), "test");
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
	}
	public class MainActivity extends Activity {
		private ImageView mImage;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			mImage = (ImageView) findViewById(R.id.Iv);
			new ImageAsynTask(mImage, "http://img1.3lian.com/img2011/07/20/05.jpg")
					.execute();
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<ImageView
			android:id="@+id/Iv"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:layout_gravity="center"
			android:src="@drawable/load" />
	</LinearLayout>
//网站源代码查看器 
	public class HtmlAsynTask extends AsyncTask<Void, Void, String> {
		private TextView m;
		private String url;
		public HtmlAsynTask(TextView i,String t){
			m = i;
			url = t;
		}
		@Override
		protected String doInBackground(Void... params) {
			return requestByHttpGet(url);
		}
		@Override
		protected void onPostExecute(String result) {
			super.onPostExecute(result);
			if (null != result) {
				m.setText(result);
			}
			else{
				m.setText("加载失败");
			}
		}
		@Override
		protected void onPreExecute() {
			super.onPreExecute();
		}
		public String requestByHttpGet(String url) {
			HttpGet httpGet = new HttpGet(url);
			HttpClient httpClient = new DefaultHttpClient();
			HttpResponse httpResp;
			try {
				httpResp = httpClient.execute(httpGet);
				if (httpResp.getStatusLine().getStatusCode() == 200) {
					String result = EntityUtils.toString(httpResp.getEntity(), "UTF-8");
					Log.e("TAG", "HttpGet方式请求成功,返回数据如下:");
					return result;
				} else {
					Log.e("TAG", "HttpGet方式请求失败");
				}
			} catch (ClientProtocolException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
	}
	public class MainActivity extends Activity{
		private TextView tv;
		private EditText et;
		private Button btn;
		@Override
		protected void onCreate (Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					tv.setText("Html加载中.........");
					String str = et.getText().toString();
					new HtmlAsynTask(tv, str).execute();
				}
			});
		}
		private void findView() {
			tv = (TextView) findViewById(R.id.Tv);
			et = (EditText)findViewById(R.id.Et);
			btn = (Button)findViewById(R.id.Btn);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<EditText 
			android:id="@+id/Et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="http://www.baidu.com"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击开始加载Html"
			/>
		<ScrollView 
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			>
			<TextView
				android:id="@+id/Tv"
				android:layout_width="match_parent"
				android:layout_height="match_parent"/>
		</ScrollView>
	</LinearLayout>
//终止异步任务操作 
	public class HtmlAsynTask extends AsyncTask<Void, Void, String> {
		private TextView m;
		private String url;
		public HtmlAsynTask(TextView i,String t){
			m = i;
			url = t;
		}
		@Override
		protected String doInBackground(Void... params) {
			return requestByHttpGet(url);
		}
		@Override
		protected void onPostExecute(String result) {
			super.onPostExecute(result);
			Log.e("isCancelled()", isCancelled()+"");
			if (isCancelled()) {
				m.setText("取消加载");
			}
			else if (null != result) {
				m.setText(result);
			}
			else{
				m.setText("加载失败");
			}
		}
		@Override
		protected void onPreExecute() {
			super.onPreExecute();
		}
		public String requestByHttpGet(String url) {
			HttpGet httpGet = new HttpGet(url);
			HttpClient httpClient = new DefaultHttpClient();
			HttpResponse httpResp;
			try {
				httpResp = httpClient.execute(httpGet);
				if (httpResp.getStatusLine().getStatusCode() == 200) {
					String result = EntityUtils.toString(httpResp.getEntity(), "UTF-8");
					Log.e("TAG", "HttpGet方式请求成功,返回数据如下:");
					return result;
				} else {
					Log.e("TAG", "HttpGet方式请求失败");
				}
			} catch (ClientProtocolException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
	}
	public class MainActivity extends Activity{
		private TextView tv;
		private EditText et;
		private Button btnstart;
		private Button btnstop;
		protected HtmlAsynTask hat;
		@Override
		protected void onCreate (Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btnstart.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					tv.setText("Html加载中.........");
					String str = et.getText().toString();
					hat = new HtmlAsynTask(tv, str);
					hat.execute();
				}
			});
			btnstop.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					hat.cancel(true);
				}
			});
		}
		private void findView() {
			tv = (TextView) findViewById(R.id.Tv);
			et = (EditText)findViewById(R.id.Et);
			btnstart = (Button)findViewById(R.id.BtnStart);
			btnstop = (Button)findViewById(R.id.BtnStop);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<EditText 
			android:id="@+id/Et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="http://www.baidu.com"
			/>
		<Button 
			android:id="@+id/BtnStart"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击开始加载Html"
			/>
		<Button 
			android:id="@+id/BtnStop"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击终止加载Html"
			/>
		<ScrollView 
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			>
			<TextView
				android:id="@+id/Tv"
				android:layout_width="match_parent"
				android:layout_height="match_parent"/>
		</ScrollView>
	</LinearLayout>
//异步任务进度展示 
	public class HtmlAsynTask extends AsyncTask<Void, Void, Integer> {
		private ProgressBar m;
		public HtmlAsynTask(ProgressBar i) {
			m = i;
		}
		@Override
		protected Integer doInBackground(Void... params) {
			int i = 0;
			while (i < 100) {
				i+=10;
				publishProgress(i);
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
				}
			}
			return null;
		}
		@Override
		protected void onPostExecute(Integer result) {
			super.onPostExecute(result);

		}
		@Override
		protected void onPreExecute() {
			super.onPreExecute();
		}
		protected void publishProgress(int i) {
			m.setProgress(i);
		}
	}
	public class MainActivity extends Activity{
		private Button btn;
		private ProgressBar pb;
		@Override
		protected void onCreate (Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					new HtmlAsynTask(pb).execute();
				}
			});
		}
		private void findView() {
			btn = (Button)findViewById(R.id.Btn);
			pb = (ProgressBar)findViewById(R.id.Pb);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击开始异步任务加载"
			/>
		<ProgressBar 
			android:id="@+id/Pb"
			android:layout_width="match_parent" 
			android:layout_height="wrap_content"
			style="?android:attr/progressBarStyleHorizontal"
			android:layout_gravity="center_vertical" 
			android:max="100" /> 
	</LinearLayout>
Android程序内部的信息传递者
Android中系统Intent的使用 	
//Google搜索内容 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<EditText 
			android:id="@+id/Et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入要搜索的关键字"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击开始Google查询"
			/>    
	</LinearLayout>
	public class MainActivity extends Activity{
		private Button btn;
		private EditText Et;
		@Override
		protected void onCreate (Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent intent = new Intent(); 
					intent.setAction(Intent.ACTION_WEB_SEARCH); 
					intent.putExtra(SearchManager.QUERY,Et.getText().toString());
					startActivity(intent); 
				}
			});
		}
		private void findView() {
			btn = (Button)findViewById(R.id.Btn);
			Et = (EditText)findViewById(R.id.Et);
		}
	}
//打开浏览器浏览网页 
	public class MainActivity extends Activity{
		private Button btn;
		private EditText Et;
		@Override
		protected void onCreate (Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					String url = Et.getText().toString();
					if (!"".equals(url)) {
						Uri uri = Uri.parse("http://"+url); 
						Intent it  = new Intent(Intent.ACTION_VIEW,uri); 
						startActivity(it); 
					}
					else{
						Toast.makeText(MainActivity.this,"请输入要跳转的网址...", 
								Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
		private void findView() {
			btn = (Button)findViewById(R.id.Btn);
			Et = (EditText)findViewById(R.id.Et);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<EditText 
			android:id="@+id/Et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入要打开的网址"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击打开浏览器显示网址"
			/>    
	</LinearLayout>
//电话拨号软件 
	public class MainActivity extends Activity{
		private Button btn;
		private EditText Et;
		@Override
		protected void onCreate (Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					String phonenum = Et.getText().toString();
					if (!"".equals(phonenum)) {
						Uri uri = Uri.parse("tel:" + phonenum);
						Intent it = new Intent(Intent.ACTION_CALL, uri); 
						startActivity(it); 
					}
					else{
						Toast.makeText(MainActivity.this,"请输入您要拨打的电话号码...", 
								Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
		private void findView() {
			btn = (Button)findViewById(R.id.Btn);
			Et = (EditText)findViewById(R.id.Et);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<EditText 
			android:id="@+id/Et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入拨打的电话号码"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击开始拨打电话"
			/>    
	</LinearLayout>
//分享短信 
	public class MainActivity extends Activity{
		private Button btn;
		private EditText Et;
		@Override
		protected void onCreate (Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}

		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					String msg = Et.getText().toString();
					if (!"".equals(msg)) {
						Intent it = new Intent(Intent.ACTION_VIEW);
						it.putExtra("sms_body", msg);
						it.setType("vnd.android-dir/mms-sms");   
						startActivity(it); 
					}
					else{
						Toast.makeText(MainActivity.this,"请输入您要分享的短信内容...", 
								Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
		private void findView() {
			btn = (Button)findViewById(R.id.Btn);
			Et = (EditText)findViewById(R.id.Et);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<EditText 
			android:id="@+id/Et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入要分享的短信内容"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击开始分享"
			/>    
	</LinearLayout>
//短信发送客户端 
	public class MainActivity extends Activity {
		private Button btn;
		private EditText EtMsg;
		private EditText EtNum;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					String msg = EtMsg.getText().toString();
					String number = EtNum.getText().toString();
					if (!"".equals(msg) && !"".equals(number)) {
						SmsManager smsManager = SmsManager.getDefault();
						PendingIntent sendIntent = PendingIntent.getBroadcast(
								MainActivity.this, 0, new Intent(), 0);
						smsManager.sendTextMessage(number, null, msg, sendIntent,
								null);
						Toast.makeText(MainActivity.this, "发送成功",
								Toast.LENGTH_SHORT).show();
					} else {
						Toast.makeText(MainActivity.this, "短信号码或短信内容为空...",
								Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			EtMsg = (EditText) findViewById(R.id.EtMsg);
			EtNum = (EditText) findViewById(R.id.EtNum);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<EditText 
			android:id="@+id/EtNum"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入要接受短信的电话号码"
			/>
		<EditText 
			android:id="@+id/EtMsg"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入短信内容"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="发送短信"
			/>    
	</LinearLayout>
//彩信分享客户端 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<EditText 
			android:id="@+id/EtNum"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入要接受彩信的电话号码"
			/>
		<EditText 
			android:id="@+id/EtSub"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入彩信的主题"
			/>
		<EditText 
			android:id="@+id/EtMsg"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入彩信内容"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="发送彩信"
			/>    
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button btn;
		private EditText EtMsg;
		private EditText EtNum;
		private EditText EtSub;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					String msg = EtMsg.getText().toString();
					String number = EtNum.getText().toString();
					String sub = EtSub.getText().toString();
					if (!"".equals(msg) && !"".equals(number)
							&& !"".equals(sub)) {
						Uri uri = Uri.parse("content://media/external/images/media/01");
						Intent intent = new Intent(Intent.ACTION_SEND);
						intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
						intent.putExtra(Intent.EXTRA_STREAM,uri);
						intent.putExtra("subject", sub); 
						intent.putExtra("address", number); 
						intent.putExtra("sms_body", msg); 
						intent.putExtra(Intent.EXTRA_TEXT, "it's EXTRA_TEXT");
						intent.setType("image/*");
						intent.setClassName("com.android.mms","com.android.mms.ui.ComposeMessageActivity");
						startActivity(intent);
					} else {
						Toast.makeText(MainActivity.this, "彩信号码或彩信内容为空...",
								Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			EtMsg = (EditText) findViewById(R.id.EtMsg);
			EtNum = (EditText) findViewById(R.id.EtNum);
			EtSub = (EditText) findViewById(R.id.EtSub);
		}
	}
//Email发送客户端 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<EditText 
			android:id="@+id/EtEmail"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入要接受邮件的邮箱地址"
			/>
		<EditText 
			android:id="@+id/EtSub"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入邮件的主题"
			/>
		<EditText 
			android:id="@+id/EtMsg"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入邮件的内容"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="发送邮件"
			/>    
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button btn;
		private EditText EtMsg;
		private EditText EtEmail;
		private EditText EtSub;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					String msg = EtMsg.getText().toString();
					String emailadd = EtEmail.getText().toString();
					String sub = EtSub.getText().toString();
					if (!"".equals(msg) && !"".equals(emailadd)
							&& !"".equals(sub)) {
						Intent i = new Intent(Intent.ACTION_SEND);  
						i.setType("text/plain"); //模拟器请使用这行
						i.putExtra(Intent.EXTRA_EMAIL, new String[]{emailadd});  
						i.putExtra(Intent.EXTRA_SUBJECT,sub);  
						i.putExtra(Intent.EXTRA_TEXT,msg);
						startActivity(Intent.createChooser(i, "请选择发送邮件的客户端"));
					} else {
						Toast.makeText(MainActivity.this, "接收邮件地址或邮件内容为空...",
								Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			EtMsg = (EditText) findViewById(R.id.EtMsg);
			EtEmail = (EditText) findViewById(R.id.EtEmail);
			EtSub = (EditText) findViewById(R.id.EtSub);
		}
	}
//启动多媒体播放 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击按钮播放/sdcard/song.mp3文件"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="播放声音"
			/>    
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button btn;
		private TextView Tv;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent it = new Intent(Intent.ACTION_VIEW);
					Uri uri = Uri.parse("file:///sdcard/song.mp3");
					it.setDataAndType(uri, "audio/mp3");
					startActivity(it);
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			Tv = (TextView) findViewById(R.id.Tv);
		}
	}
//安装指定的应用程序 
	public class MainActivity extends Activity {
		private Button btn;
		private TextView Tv;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent intent = new Intent(Intent.ACTION_VIEW);  
					intent.setDataAndType(Uri.parse("file://"  
							+ "/sdcard/XMNotes.apk"),  
							"application/vnd.android.package-archive");  
					startActivity(intent); 
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			Tv = (TextView) findViewById(R.id.Tv);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击安装file:///sdcard/XMNotes.apk文件"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="安装软件"
			/>    
	</LinearLayout>
//卸载指定的应用程序 
	public class MainActivity extends Activity {
		private Button btn;
		private TextView Tv;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}

		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Uri packageURI = Uri.parse("package:com.xiaomi.notes");   
					Intent uninstallIntent = new Intent(Intent.ACTION_DELETE,
							packageURI);   
					startActivity(uninstallIntent); 
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			Tv = (TextView) findViewById(R.id.Tv);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击卸载com.xiaomi.notes软件"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="卸载软件"
			/>    
	</LinearLayout>
//打开照相机获取图片 
	public class MainActivity extends Activity {
		private Button btn;
		private TextView Tv;
		private ImageView Iv;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);  
					startActivityForResult(intent, 1);
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			Tv = (TextView) findViewById(R.id.Tv);
			Iv = (ImageView) findViewById(R.id.Iv);
		}
		@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			super.onActivityResult(requestCode, resultCode, data);
			if (requestCode == 1) {
				if (resultCode == RESULT_OK) {
					Bitmap bmPhoto = (Bitmap) data.getExtras().get("data");
					Iv.setImageBitmap(bmPhoto);
				}
			}
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击拍照预览效果"
			/>
		<ImageView 
			android:id="@+id/Iv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:src="@drawable/ic_launcher"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击按钮使用摄像头拍照"
			/>
	</LinearLayout>
//打开系统图库获取图片 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击浏览系统照片效果"
			/>
		<ImageView 
			android:id="@+id/Iv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:src="@drawable/ic_launcher"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击按钮选择系统照片"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button btn;
		private TextView Tv;
		private ImageView Iv;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent intent = new Intent();  
					intent.setType("image/*");  
					intent.setAction(Intent.ACTION_GET_CONTENT);   
					startActivityForResult(intent, 1); 
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			Tv = (TextView) findViewById(R.id.Tv);
			Iv = (ImageView) findViewById(R.id.Iv);
		}
		@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			super.onActivityResult(requestCode, resultCode, data);
			if (requestCode == 1) {
				if (resultCode == RESULT_OK) {
					Uri uri = data.getData();  
					ContentResolver cr = this.getContentResolver();  
					try {  
						Bitmap bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri));  
						Iv.setImageBitmap(bitmap);  
					} catch (FileNotFoundException e) {  
						Log.e("Exception", e.getMessage(),e);  
					}  
				}
			}
		}
	}
//打开录音程序录音 
	public class MainActivity extends Activity {
		private Button btn;
		private TextView Tv;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent intent = new Intent(Media.RECORD_SOUND_ACTION);
					startActivityForResult(intent, 1);  
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			Tv = (TextView) findViewById(R.id.Tv);
		}
		@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			super.onActivityResult(requestCode, resultCode, data);
			if (requestCode == 1) {
				if (resultCode == RESULT_OK) {
					String dataFile=data.getDataString() ;
					String dataUri=getIntent().getDataString();
					Log.e("dataFile", dataFile);
					Log.e("dataUri", dataUri);
				}
			}
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击下面的打开录音机的按钮"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击打开录音机"
			/>
	</LinearLayout>
//打开已安装的应用程序信息 
	public class MainActivity extends Activity {
		private Button btn;
		private EditText Et;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); 
					Uri uri = Uri.fromParts("package",Et.getText().toString(), null);  
					intent.setData(uri);  
					startActivity(intent);  
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			Et = (EditText) findViewById(R.id.Et);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击下面的打开软件信息的按钮"
			/>
		<EditText 
			android:id="@+id/Et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="com.wyl.example"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击打开应用信息"
			/>
	</LinearLayout>
//打开软件市场搜索应用 
	public class MainActivity extends Activity {
		private Button btn;
		private EditText Et;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Uri uri = Uri.parse("market://search?q=pname:"
							+Et.getText().toString());
					Intent it = new Intent(Intent.ACTION_VIEW, uri);
					startActivity(it);
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			Et = (EditText) findViewById(R.id.Et);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击下面的查找软件的按钮"
			/>
		<EditText 
			android:id="@+id/Et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="小米便签"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击查找应用"
			/>
	</LinearLayout>
//选择联系人功能 
	public class MainActivity extends Activity {
		private Button btn;

		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent intent = new Intent();  
					intent.setAction(Intent.ACTION_VIEW);   
					intent.setData(Contacts.People.CONTENT_URI);  
					startActivity(intent);
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击下面的打开联系人界面的按钮"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击打开联系人应用"
			/>
	</LinearLayout>
//添加联系人功能 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击下面的添加联系人界面的按钮"
			/>
		<EditText 
			android:id="@+id/EtName"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="联系人姓名"
			/>
		<EditText 
			android:id="@+id/EtPhone"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="联系人电话"
			/>
		<EditText 
			android:id="@+id/EtEmail"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="联系人邮箱"
			/>
		<EditText 
			android:id="@+id/EtCompany"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="联系人公司"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击添加联系人应用"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button btn;
		private EditText EtName;
		private EditText EtPhone;
		private EditText EtEmail;
		private EditText EtCompany;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent it = new Intent(Contacts.Intents.Insert.ACTION);
					it.setType(Contacts.People.CONTENT_TYPE);
					it.putExtra(Contacts.Intents.Insert.NAME, EtName.getText().toString());
					it.putExtra(Contacts.Intents.Insert.PHONE, EtPhone.getText().toString());
					it.putExtra(Contacts.Intents.Insert.EMAIL, EtEmail.getText().toString());
					it.putExtra(Contacts.Intents.Insert.COMPANY, EtCompany.getText().toString());
					startActivity(it);
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			EtName = (EditText) findViewById(R.id.EtName);
			EtPhone = (EditText) findViewById(R.id.EtPhone);
			EtEmail = (EditText) findViewById(R.id.EtEmail);
			EtCompany = (EditText) findViewById(R.id.EtCompany);
		}
	}
//程序内部启动外部程序 
	public class MainActivity extends Activity {
		private Button btn;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent intent = new Intent(); 
					intent = getPackageManager().
							getLaunchIntentForPackage("com.xiaomi.notes"); 
					startActivity(intent);
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击下面的启动小米便签的按钮"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击启动小米便签"
			/>
	</LinearLayout>
//启动Google地图显示某个位置 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击下面的启动谷歌地图"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击启动谷歌地图"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button btn;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Uri uri = Uri.parse("geo:39.888402,116.409561");
					Intent it = new Intent(Intent.ACTION_VIEW,uri);
					startActivity(it);
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
		}
	}
//启动Google地图进行路径规划 
	public class MainActivity extends Activity {
		private Button btn;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Uri uri = Uri.parse("https://maps.google.com/maps?f=d&saddr=39.88445+116.257217&daddr=39.985538+116.544921&hl=cn");
					Intent it = new Intent(Intent.ACTION_VIEW,uri);
					startActivity(it);
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView 
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="点击启动谷歌地图进行路径规划"
			/>
		<Button 
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动谷歌地图进行路径规划"
			/>
	</LinearLayout>
//登录页面功能 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="恭喜您已登录" />
	</LinearLayout>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal" >
			<TextView
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_weight="2"
				android:text="用户名:" />
			<EditText
				android:id="@+id/EtName"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:hint="用户名" />
		</LinearLayout>
		<LinearLayout
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:orientation="horizontal" >
			<TextView
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_weight="2"
				android:text="密码:" />
			<EditText
				android:id="@+id/EtPwd"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:numeric="integer"
				android:password="true"
				android:hint="密码" />
		</LinearLayout>
		<Button
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="登录" />
	</LinearLayout>
	public class SecActivity extends Activity {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_sec);
			Intent i = getIntent();
			String name = i.getStringExtra("USERNAME");
			TextView tv = (TextView)findViewById(R.id.Tv);
			tv.setText(name+",欢迎您登录本系统");
		}
	}
	public class MainActivity extends Activity {
		private Button btn;
		private EditText EtName;
		private EditText EtPwd;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					String name = EtName.getText().toString();
					String pwd = EtPwd.getText().toString();
					if (isUser(name,pwd)) {
						Intent i = new Intent(MainActivity.this,SecActivity.class);
						i.putExtra("USERNAME", name);
						startActivity(i);
					}
					else{
						Toast.makeText(MainActivity.this, "用户名密码错误",
								Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
		protected boolean isUser(String name, String pwd) {
			if ("admin".equals(name) && "123".equals(pwd)) {
				return true;
			}
			else{
				return false;
			}
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			EtName = (EditText) findViewById(R.id.EtName);
			EtPwd = (EditText) findViewById(R.id.EtPwd);
		}
	}
//注册页面功能 
	public class MainActivity extends Activity {
		private Button btn;
		private EditText EtName;
		private EditText EtPwd;
		private EditText EtEmail;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					String name = EtName.getText().toString();
					String pwd = EtPwd.getText().toString();
					String email = EtEmail.getText().toString();
					if (!"".equals(name)
							&& !"".equals(pwd)
							&& !"".equals(email)) {
						User u = new User();
						u.setEamil(email);
						u.setName(name);
						u.setPwd(pwd);
						Intent i = new Intent(MainActivity.this,SecActivity.class);
						i.putExtra("USER", u);
						startActivity(i);
					}
					else{
						Toast.makeText(MainActivity.this, 
								"输入信息为空",Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			EtName = (EditText) findViewById(R.id.EtName);
			EtPwd = (EditText) findViewById(R.id.EtPwd);
			EtEmail = (EditText) findViewById(R.id.EtEmail);
		}
	}
	public class SecActivity extends Activity {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_sec);
			Intent i = getIntent();
			User u = (User) i.getSerializableExtra("USER");
			TextView tv = (TextView)findViewById(R.id.Tv);
			tv.setText("用户的注册信息为:"+u.toString());
		}
	}
	public class User implements Serializable{
		private static final long serialVersionUID = 1L;
		public String name;
		public String pwd;
		public String eamil;
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public String getPwd() {
			return pwd;
		}
		public void setPwd(String pwd) {
			this.pwd = pwd;
		}
		public String getEamil() {
			return eamil;
		}
		public void setEamil(String eamil) {
			this.eamil = eamil;
		}
		@Override
		public String toString() {
			return "User [name=" + name + ", pwd=" + pwd + ", eamil=" + eamil + "]";
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal" >
			<TextView
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_weight="2"
				android:text="用户名:" />
			<EditText
				android:id="@+id/EtName"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:hint="用户名" />
		</LinearLayout>
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal" >
			<TextView
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_weight="2"
				android:text="密码:" />
			<EditText
				android:id="@+id/EtPwd"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:hint="密码" />
		</LinearLayout>
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal" >
			<TextView
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_weight="2"
				android:text="邮箱:" />
			<EditText
				android:id="@+id/EtEmail"
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:hint="邮箱" />
		</LinearLayout>
		<Button
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="注册" />
	</LinearLayout>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"/>
	</LinearLayout>
//获取随机验证码功能 
	public class MainActivity extends Activity {
		private Button btn;
		private TextView Tv;
		protected static final int MyrequestCode = 100;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent i = new Intent(MainActivity.this, SecActivity.class);
					startActivityForResult(i, MyrequestCode);
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			Tv = (TextView) findViewById(R.id.Tv);
		}
		@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			super.onActivityResult(requestCode, resultCode, data);
			if (requestCode == MyrequestCode) {
				int res = data.getIntExtra("RANDOM", 0);
				Tv.setText("您获取的随机数是:"+res);
			}
		}
	}
	public class SecActivity extends Activity {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_sec);
			Intent i = getIntent();
			int r=(int)(Math.random()*1000);
			i.putExtra("RANDOM", r);
			setResult(MainActivity.MyrequestCode, i);
			finish();
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"/>
	</LinearLayout>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击获取随机数验证码" />
		<Button
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="获取随机数验证码" />
	</LinearLayout>
//模拟站内搜索 
	public class MainActivity extends Activity {
		private Button btn;
		private EditText Et;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			btn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					String key = Et.getText().toString();
					if (!"".equals(key)) {
						Intent i = new Intent();
						i.setAction("wyl.com.test");
						i.putExtra("KEY",key);
						startActivity(i);
					}
					else{
						Toast.makeText(MainActivity.this,
								"搜索关键字为空",Toast.LENGTH_SHORT).show();
					}
					
				}
			});
		}
		private void findView() {
			btn = (Button) findViewById(R.id.Btn);
			Et = (EditText) findViewById(R.id.Et);
		}
	}
	public class SecActivity extends Activity {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_sec);
			Intent i = getIntent();
			String key = i.getStringExtra("KEY");
			TextView tv = (TextView)findViewById(R.id.Tv);
			tv.setText("您要搜索的关键字是:"+key);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击跳转站内搜索效果" />
		<EditText
			android:id="@+id/Et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="请输入搜索关键字" />
		<Button
			android:id="@+id/Btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="点击跳转站内搜索页面" />
	</LinearLayout>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"/>
	</LinearLayout>

Android的数据存储 
Android中的文件操作 
//可记住用户名密码的登录界面 
	public class MainActivity extends Activity {
		private EditText mEtUserName; 
		private EditText mEtPassWord;
		private CheckBox mCbKeepPsd; 
		private Button mBtnLogin; 
		private SharedPreferences mSpSettings = null;
		private static final String PREFS_NAME = "NamePwd";
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
			getData();
		}
		private void findView() {
			mEtUserName = (EditText) findViewById(R.id.et_username);
			mEtPassWord = (EditText) findViewById(R.id.et_password);
			mCbKeepPsd = (CheckBox) findViewById(R.id.cb_keeppsd);
			mBtnLogin = (Button) findViewById(R.id.btn_login);
		}
		private void setListener() {
			mBtnLogin.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					if ("wyl".equals(mEtUserName.getText().toString())
							&& "123".equals(mEtPassWord.getText().toString())) {
						if (mCbKeepPsd.isChecked()) {
							mSpSettings = getSharedPreferences(PREFS_NAME,
									MODE_PRIVATE);
							Editor edit = mSpSettings.edit();
							edit.putBoolean("isKeep", true);
							edit.putString("username", mEtUserName.getText()
									.toString());
							edit.putString("password", mEtPassWord.getText()
									.toString());
							edit.commit(); 
						} else {
							mSpSettings = getSharedPreferences(PREFS_NAME,
									MODE_PRIVATE);
							Editor edit = mSpSettings.edit();
							edit.putBoolean("isKeep", false);
							edit.putString("username", "");
							edit.putString("password", "");
							edit.commit(); 
						}
						Intent intent = new Intent(MainActivity.this,
								SuccessActivity.class);
						startActivity(intent);
					} else {
						Toast.makeText(getApplicationContext(), "用户名或密码错误",
								Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
		@Override
		protected void onResume() {
			super.onResume();
			getData();
		}
		private void getData() {
			mSpSettings = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
			if (mSpSettings.getBoolean("isKeep", false)) {
				mEtUserName.setText(mSpSettings.getString("username", ""));
				mEtPassWord.setText(mSpSettings.getString("password", ""));
			} else {
				mEtUserName.setText("");
				mEtPassWord.setText("");
			}
		}
	}
	public class SuccessActivity extends Activity {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.success_main);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_margin="10dp"
			android:orientation="horizontal" >
			<TextView
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:layout_marginRight="5dp"
				android:text="@string/tv_username" />
			<EditText
				android:id="@+id/et_username"
				android:layout_weight="3"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content" />
		</LinearLayout>
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_margin="10dp"
			android:orientation="horizontal" >
			<TextView
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:layout_marginRight="5dp"
				android:text="@string/tv_password" />
			<EditText
				android:id="@+id/et_password"
				android:layout_weight="3"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:password="true" />
		</LinearLayout>
		<LinearLayout
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_marginLeft="10dp"
			android:layout_marginRight="10dp"
			android:layout_marginTop="5dp"
			android:orientation="horizontal" >
			<CheckBox
				android:id="@+id/cb_keeppsd"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="@string/cb_keeppsd" 
				android:checked="true"/>
			<Button
				android:id="@+id/btn_login"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_weight="3"
				android:layout_marginLeft="20dp"
				android:text="@string/btn_login" />
		</LinearLayout>
	</LinearLayout>
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<TextView
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_centerInParent="true"
			android:text="@string/tv_success"
			android:textSize="20sp" />
	</RelativeLayout>
//系统的设置界面 
	public class MainActivity extends Activity {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			Button btnSetting = (Button)findViewById(R.id.btn_setting);
			btnSetting.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					Intent intent = new Intent(MainActivity.this, SettingActivity.class);
					startActivity(intent);
				}
			});
		}
	}
	public class PreferenceSetting extends PreferenceFragment implements
		OnPreferenceClickListener, OnPreferenceChangeListener {
	private CheckBoxPreference mapply_wifiPreference; 
	private CheckBoxPreference mapply_internetPreference; 
	private ListPreference depart_valuePreference; 
	private EditTextPreference number_editPreference; 
	private Preference mwifi_settingPreference;
	private Context mContext;
	private static final String TAG = "PreferenceSetting";
	public PreferenceSetting(Context context) {
		mContext = context;
	}
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.mypreference);
		findView();
		setListener();
	}
	private void findView() {
		mapply_wifiPreference = (CheckBoxPreference) findPreference("apply_wifi");
		mapply_internetPreference = (CheckBoxPreference) findPreference("apply_internet");
		depart_valuePreference = (ListPreference) findPreference("depart_value");
		number_editPreference = (EditTextPreference) findPreference("number_edit");
		mwifi_settingPreference = (Preference) findPreference("wifi_setting");
	}
	private void setListener() {
		mapply_internetPreference.setOnPreferenceClickListener(this);
		mapply_internetPreference.setOnPreferenceChangeListener(this);
		depart_valuePreference.setOnPreferenceClickListener(this);
		depart_valuePreference.setOnPreferenceChangeListener(this);
		number_editPreference.setOnPreferenceClickListener(this);
		number_editPreference.setOnPreferenceChangeListener(this);
		mwifi_settingPreference.setOnPreferenceClickListener(this);
	}
	@Override
	public boolean onPreferenceClick(Preference preference) {
		Log.e(TAG,
				"onPreferenceClick----->" + String.valueOf(preference.getKey()));
		return false;
	}
	@Override
	public boolean onPreferenceChange(Preference preference, Object objValue) {
		Log.i(TAG,
				"onPreferenceChange----->"
						+ String.valueOf(preference.getKey()));
		if (preference == mapply_wifiPreference) {
			Log.i(TAG, "Wifi CB, and isCheckd = " + String.valueOf(objValue));
		} else if (preference.getKey().equals("apply_internet")) {
			Log.i(TAG,
					"internet CB, and isCheckd = " + String.valueOf(objValue));
		} else if (preference == depart_valuePreference) {
			Log.i(TAG, "  Old Value" + depart_valuePreference.getValue()
					+ " NewDeptName" + objValue);
		} else if (preference.getKey().equals("wifi_setting")) {
			Log.i(TAG, "change" + String.valueOf(objValue));
			mwifi_settingPreference.setTitle("its turn me."); 
		} else if (preference == number_editPreference) {
			Log.i(TAG, "Old Value = " + String.valueOf(objValue));
		}
		return true; 
	}
	@Override
	public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
				Preference preference) {
			Log.i(TAG, "onPreferenceTreeClick----->" + preference.getKey());
			if (preference == mapply_wifiPreference) {
				Log.e(TAG,
						" Wifi , and isCheckd ="
								+ mapply_wifiPreference.isChecked());
			} else if (preference.getKey().equals("apply_internet")) {
				Log.e(TAG, " internet , and isCheckd = "
						+ mapply_internetPreference.isChecked());
			} else if (preference == depart_valuePreference) {
				Log.e(TAG, " department CB,and selectValue = "
						+ depart_valuePreference.getValue() + ", Text="
						+ depart_valuePreference.getEntry());
			} else if (preference.getKey().equals("wifi_setting")) {
				Log.e(TAG,
						" wifi , and isCheckd = "
								+ mapply_wifiPreference.isChecked());
			} else if (preference == number_editPreference) {
				Log.e(TAG, "Old Value=" + number_editPreference.getText()
						+ ", New Value="
						+ number_editPreference.getEditText().toString());
			}
			if (preference.getKey().equals("wifi_setting")) {
				Intent i = new Intent(mContext, WifiSettingActivity.class); 
				startActivity(i);
				return true;
			}
			return super.onPreferenceTreeClick(preferenceScreen, preference);
		}
	}
	public class SettingActivity extends Activity{
		@SuppressLint("NewApi")
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			FragmentManager fragmentManager = getFragmentManager();  
			FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();  
			PreferenceSetting setting = new PreferenceSetting(this);  
			fragmentTransaction.replace(android.R.id.content, setting);          
			fragmentTransaction.addToBackStack(null);   
			fragmentTransaction.commit(); 
		}
	}
	public class WifiSettingActivity extends Activity {
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.wifisetting_main);
		}
	}
	<LinearLayout 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=".MainActivity" >
		<Button
			android:id="@+id/btn_setting"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_centerInParent="true"
			android:text="@string/setting" />
	</LinearLayout>
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<TextView
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_centerInParent="true"
			android:text="WIFI设置页面"
			android:textSize="20sp" />
	</RelativeLayout>
//系统图片剪裁 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<ImageView
			android:id="@+id/imageView"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" />
		<Button
			android:id="@+id/selectImageBtn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="选择图片" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private static final int TAKE_PICTURE = 0;   	
		private static final int CHOOSE_PICTURE = 1;	
		private static final int CROP = 2;			
		private static final int CROP_PICTURE = 3;
		private Button mBtnSlect; 
		private ImageView mIvShow;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			mBtnSlect = (Button) findViewById(R.id.selectImageBtn);
			mIvShow = (ImageView) findViewById(R.id.imageView);
		}
		private void setListener() {
			mBtnSlect.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					showPicturePicker(MainActivity.this);
				}
			});
		}
		public void showPicturePicker(Context context) {
			AlertDialog.Builder builder = new AlertDialog.Builder(context);
			builder.setTitle("图片来源");
			builder.setNegativeButton("取消", null);
			builder.setItems(new String[] { "拍照", "相册" },
					new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
							switch (which) {
							case TAKE_PICTURE:
								Uri imageUri = null;
								String fileName = null;
								Intent openCameraIntent = new Intent(
										MediaStore.ACTION_IMAGE_CAPTURE);
								SharedPreferences sharedPreferences = getSharedPreferences(
										"temp", Context.MODE_WORLD_WRITEABLE);
								ImageTools.deletePhotoAtPathAndName(Environment
										.getExternalStorageDirectory()
										.getAbsolutePath(), sharedPreferences
										.getString("tempName", ""));
								fileName = String.valueOf(System
										.currentTimeMillis()) + ".jpg";
								Editor editor = sharedPreferences.edit();
								editor.putString("tempName", fileName);
								editor.commit();
								imageUri = Uri.fromFile(new File(Environment
										.getExternalStorageDirectory(), fileName));
								openCameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,
										imageUri);
								startActivityForResult(openCameraIntent,
										CROP);
								break;
							case CHOOSE_PICTURE:
								Intent openAlbumIntent = new Intent(
										Intent.ACTION_GET_CONTENT);
								openAlbumIntent
										.setDataAndType(
												MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
												"image/*");
								startActivityForResult(openAlbumIntent,
										CROP);
								break;
							default:
								break;
							}
						}
					});
			builder.create().show();
		}
		@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			super.onActivityResult(requestCode, resultCode, data);
			if (resultCode == RESULT_OK) {
				switch (requestCode) {
				case CROP:
					Uri uri = null;
					if (data != null) {
						uri = data.getData();
					} else {
						String fileName = getSharedPreferences("temp",
								Context.MODE_WORLD_WRITEABLE).getString("tempName",
								"");
						uri = Uri.fromFile(new File(Environment
								.getExternalStorageDirectory(), fileName));
					}
					cropImage(uri, 500, 500, CROP_PICTURE);
					break;
				case CROP_PICTURE:
					Bitmap photo = null;
					Uri photoUri = data.getData();
					if (photoUri != null) {
						photo = BitmapFactory.decodeFile(photoUri.getPath());
					}
					if (photo == null) {
						Bundle extra = data.getExtras();
						if (extra != null) {
							photo = (Bitmap) extra.get("data");
							ByteArrayOutputStream stream = new ByteArrayOutputStream();
							photo.compress(Bitmap.CompressFormat.JPEG, 100, stream);
						}
					}
					mIvShow.setImageBitmap(photo);
					break;
				default:
					break;
				}
			}
		}
		public void cropImage(Uri uri, int outputX, int outputY, int requestCode) {
			Intent intent = new Intent("com.android.camera.action.CROP");
			intent.setDataAndType(uri, "image/*");
			intent.putExtra("crop", "true");
			intent.putExtra("aspectX", 1); 	
			intent.putExtra("aspectY", 1);	
			intent.putExtra("outputX", outputX);  
			intent.putExtra("outputY", outputY);
			intent.putExtra("outputFormat", "JPEG"); 
			intent.putExtra("noFaceDetection", true);
			intent.putExtra("return-data", true);
			startActivityForResult(intent, requestCode);
		}
	}
	public final class ImageTools {

		/**
		 * drawable 转换 bitmap
		 * 
		 * @param drawable
		 * @return
		 */
		public static Bitmap drawableToBitmap(Drawable drawable) {
			int w = drawable.getIntrinsicWidth();
			int h = drawable.getIntrinsicHeight();

			Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
					: Bitmap.Config.RGB_565;
			Bitmap bitmap = Bitmap.createBitmap(w, h, config);
			Canvas canvas = new Canvas(bitmap);
			drawable.setBounds(0, 0, w, h);
			drawable.draw(canvas);
			return bitmap;
		}

		/**
		 * Bitmap 转换 drawable
		 * 
		 * @param bitmap
		 * @return
		 */
		public static Drawable bitmapToDrawable(Bitmap bitmap) {
			return new BitmapDrawable(bitmap);
		}

		/**
		 * Input stream to bitmap
		 * 输入流转bitmap
		 * @param inputStream
		 * @return
		 * @throws Exception
		 */
		public static Bitmap inputStreamToBitmap(InputStream inputStream)
				throws Exception {
			return BitmapFactory.decodeStream(inputStream);
		}

		/**
		 * Byte transfer to bitmap
		 * 字节转bitmap
		 * @param byteArray
		 * @return
		 */
		public static Bitmap byteToBitmap(byte[] byteArray) {
			if (byteArray.length != 0) {
				return BitmapFactory
						.decodeByteArray(byteArray, 0, byteArray.length);
			} else {
				return null;
			}
		}

		/**
		 * Byte transfer to drawable
		 * 字节转drawable
		 * @param byteArray
		 * @return
		 */
		public static Drawable byteToDrawable(byte[] byteArray) {
			ByteArrayInputStream ins = null;
			if (byteArray != null) {
				ins = new ByteArrayInputStream(byteArray);
			}
			return Drawable.createFromStream(ins, null);
		}

		/**
		 * Bitmap transfer to bytes
		 * bitmap 转 bytes
		 * @param byteArray
		 * @return
		 */
		public static byte[] bitmapToBytes(Bitmap bm) {
			byte[] bytes = null;
			if (bm != null) {
				ByteArrayOutputStream baos = new ByteArrayOutputStream();
				bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
				bytes = baos.toByteArray();
			}
			return bytes;
		}

		/**
		 * Drawable transfer to bytes
		 * Drawable 转 bytes
		 * @param drawable
		 * @return
		 */
		public static byte[] drawableToBytes(Drawable drawable) {
			BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
			Bitmap bitmap = bitmapDrawable.getBitmap();
			byte[] bytes = bitmapToBytes(bitmap);
			;
			return bytes;
		}

		/**
		 * Create reflection images
		 *  镜像转换
		 * @param bitmap
		 * @return
		 */
		public static Bitmap createReflectionImageWithOrigin(Bitmap bitmap) {
			final int reflectionGap = 4;
			int w = bitmap.getWidth();
			int h = bitmap.getHeight();

			Matrix matrix = new Matrix();
			matrix.preScale(1, -1);

			Bitmap reflectionImage = Bitmap.createBitmap(bitmap, 0, h / 2, w,
					h / 2, matrix, false);

			Bitmap bitmapWithReflection = Bitmap.createBitmap(w, (h + h / 2),
					Config.ARGB_8888);

			Canvas canvas = new Canvas(bitmapWithReflection);
			canvas.drawBitmap(bitmap, 0, 0, null);
			Paint deafalutPaint = new Paint();
			canvas.drawRect(0, h, w, h + reflectionGap, deafalutPaint);

			canvas.drawBitmap(reflectionImage, 0, h + reflectionGap, null);

			Paint paint = new Paint();
			LinearGradient shader = new LinearGradient(0, bitmap.getHeight(), 0,
					bitmapWithReflection.getHeight() + reflectionGap, 0x70ffffff,
					0x00ffffff, TileMode.CLAMP);
			paint.setShader(shader);
			// Set the Transfer mode to be porter duff and destination in
			paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
			// Draw a rectangle using the paint with our linear gradient
			canvas.drawRect(0, h, w, bitmapWithReflection.getHeight()
					+ reflectionGap, paint);

			return bitmapWithReflection;
		}

		/**
		 * Get rounded corner images
		 * 生成圆角图片
		 * @param bitmap
		 * @param roundPx
		 *            5 10
		 * @return
		 */
		public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, float roundPx) {
			int w = bitmap.getWidth();
			int h = bitmap.getHeight();
			Bitmap output = Bitmap.createBitmap(w, h, Config.ARGB_8888);
			Canvas canvas = new Canvas(output);
			final int color = 0xff424242;
			final Paint paint = new Paint();
			final Rect rect = new Rect(0, 0, w, h);
			final RectF rectF = new RectF(rect);
			paint.setAntiAlias(true);
			canvas.drawARGB(0, 0, 0, 0);
			paint.setColor(color);
			canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
			paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
			canvas.drawBitmap(bitmap, rect, rect, paint);

			return output;
		}

		/**
		 * Resize the bitmap
		 * bitmap调整大小
		 * @param bitmap
		 * @param width
		 * @param height
		 * @return
		 */
		public static Bitmap zoomBitmap(Bitmap bitmap, int width, int height) {
			int w = bitmap.getWidth();
			int h = bitmap.getHeight();
			Matrix matrix = new Matrix();
			float scaleWidth = ((float) width / w);
			float scaleHeight = ((float) height / h);
			matrix.postScale(scaleWidth, scaleHeight);
			Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
			return newbmp;
		}

		/**
		 * Resize the drawable
		 * drawable 调整大小
		 * @param drawable
		 * @param w
		 * @param h
		 * @return
		 */
		public static Drawable zoomDrawable(Drawable drawable, int w, int h) {
			int width = drawable.getIntrinsicWidth();
			int height = drawable.getIntrinsicHeight();
			Bitmap oldbmp = drawableToBitmap(drawable);
			Matrix matrix = new Matrix();
			float sx = ((float) w / width);
			float sy = ((float) h / height);
			matrix.postScale(sx, sy);
			Bitmap newbmp = Bitmap.createBitmap(oldbmp, 0, 0, width, height,
					matrix, true);
			return new BitmapDrawable(newbmp);
		}
		
		/**
		 * Get images from SD card by path and the name of image
		 * 得到存储的图片
		 * @param photoName
		 * @return
		 */
		public static Bitmap getPhotoFromSDCard(String path,String photoName){
			Bitmap photoBitmap = BitmapFactory.decodeFile(path + "/" +photoName +".png");
			if (photoBitmap == null) {
				return null;
			}else {
				return photoBitmap;
			}
		}
		
		/**
		 * Check the SD card 
		 * 检测SD卡
		 * @return
		 */
		public static boolean checkSDCardAvailable(){
			return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
		}
		
		/**
		 * Get image from SD card by path and the name of image
		 * 
		 * @param fileName
		 * @return
		 */
		public static boolean findPhotoFromSDCard(String path,String photoName){
			boolean flag = false;
			
			if (checkSDCardAvailable()) {
				File dir = new File(path);
				if (dir.exists()) {
					File folders = new File(path);
					File photoFile[] = folders.listFiles();
					for (int i = 0; i < photoFile.length; i++) {
						String fileName = photoFile[i].getName().split("\\.")[0];
						if (fileName.equals(photoName)) {
							flag = true;
						}
					}
				}else {
					flag = false;
				}
				
			}else {
				flag = false;
			}
			return flag;
		}
		
		/**
		 * Save image to the SD card 
		 * 将图片bitmap图片存储到SD卡
		 * @param photoBitmap
		 * @param photoName
		 * @param path
		 */
		public static void savePhotoToSDCard(Bitmap photoBitmap,String path,String photoName){
			if (checkSDCardAvailable()) {
				File dir = new File(path);
				if (!dir.exists()){
					dir.mkdirs();
				}
				
				File photoFile = new File(path , photoName + ".png");
				FileOutputStream fileOutputStream = null;
				try {
					fileOutputStream = new FileOutputStream(photoFile);
					if (photoBitmap != null) {
						if (photoBitmap.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream)) {
							fileOutputStream.flush();
						}
					}
				} catch (FileNotFoundException e) {
					photoFile.delete();
					e.printStackTrace();
				} catch (IOException e) {
					photoFile.delete();
					e.printStackTrace();
				} finally{
					try {
						fileOutputStream.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			} 
		}
		
		/**
		 * Delete the image from SD card
		 * 删除指定图片
		 * @param context
		 * @param path
		 * file:///sdcard/temp.jpg
		 */
		public static void deleteAllPhoto(String path){
			if (checkSDCardAvailable()) {
				File folder = new File(path);
				File[] files = folder.listFiles();
				for (int i = 0; i < files.length; i++) {
					files[i].delete();
				}
			}
		}
		
		public static void deletePhotoAtPathAndName(String path,String fileName){
			if (checkSDCardAvailable()) {
				File folder = new File(path);
				File[] files = folder.listFiles();
				for (int i = 0; i < files.length; i++) {
					System.out.println(files[i].getName());
					if (files[i].getName().equals(fileName)) {
						files[i].delete();
					}
				}
			}
		}
	}
//SDCard信息查询 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<TextView
			android:id="@+id/tv_TotalBlocks"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" />
		<TextView
			android:id="@+id/tv_BlocSize"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" />
		<TextView
			android:id="@+id/tv_AvailaBlock"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" />
		<TextView
			android:id="@+id/tv_FreeBlock"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" />
		<TextView
			android:id="@+id/tv_SDTotalSize"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" />
		<TextView
			android:id="@+id/tv_SDFreeSize"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private TextView mTvTotalBlocks;		
		private TextView mTvBlocSize;		
		private TextView mTvAvailaBlock;		
		private TextView mTvFreeBlock;			
		private TextView mTvSDTotalSize;		
		private TextView mTvSDFreeSize;			
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			SDCardSizeTest();
		}
		private void findView() {
			mTvTotalBlocks = (TextView)findViewById(R.id.tv_TotalBlocks);
			mTvBlocSize = (TextView)findViewById(R.id.tv_BlocSize);
			mTvAvailaBlock = (TextView)findViewById(R.id.tv_AvailaBlock);
			mTvFreeBlock = (TextView)findViewById(R.id.tv_FreeBlock);
			mTvSDTotalSize = (TextView)findViewById(R.id.tv_SDTotalSize);
			mTvSDFreeSize = (TextView)findViewById(R.id.tv_SDFreeSize);
		}
		public void SDCardSizeTest() {
			String sDcString = android.os.Environment.getExternalStorageState();
			if (sDcString.equals(android.os.Environment.MEDIA_MOUNTED)) {
				File pathFile = android.os.Environment
						.getExternalStorageDirectory();
				android.os.StatFs statfs = new android.os.StatFs(pathFile.getPath());
				long nTotalBlocks = statfs.getBlockCount();
				mTvTotalBlocks.setText("SDCard上BLOCK总数: "+nTotalBlocks);
				long nBlocSize = statfs.getBlockSize();
				mTvBlocSize.setText("SDCard上每个bloc的SIZE:"+nBlocSize);
				long nAvailaBlock = statfs.getAvailableBlocks();
				mTvAvailaBlock.setText("可供程序使用的Block的数量 : " + nAvailaBlock);
				long nFreeBlock = statfs.getFreeBlocks();
				mTvFreeBlock.setText("剩下的所有Block的数量: " + nFreeBlock);
				long nSDTotalSize = nTotalBlocks * nBlocSize / 1024 / 1024;
				mTvSDTotalSize.setText("SDCard 总容量大小MB: " + nSDTotalSize +"MB");
				long nSDFreeSize = nAvailaBlock * nBlocSize / 1024 / 1024;
				mTvSDFreeSize.setText(" SDCard 剩余大小MB: " + nSDFreeSize +"MB");
			}
		}
	}
//图片旋转保存 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<ImageView
			android:id="@+id/imageView"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" />
		<Button
			android:id="@+id/selectImageBtn"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:text="选择图片" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private BitmapView bitmapView = null;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			bitmapView = new BitmapView(this);
			setContentView(bitmapView);
		}
	}
	public class BitmapView extends View {
		private Matrix matrix = null;
		public BitmapView(Context context) {
			super(context);
		}
		public void onDraw(Canvas canvas) {
			Resources res = getResources();
			Bitmap bmp = BitmapFactory.decodeResource(res, R.drawable.h);
			canvas.drawColor(Color.BLACK);
			canvas.drawBitmap(bmp, 0, 0, null);
			matrix = new Matrix();
			matrix.postRotate(30);
			Bitmap bitmap = Bitmap.createBitmap(bmp, 0, 50, bmp.getWidth(),
					bmp.getHeight() / 2, matrix, true);
			canvas.drawBitmap(bitmap, 0, 250, null);
			SaveBitmap(bitmap);
		}
		public void SaveBitmap(Bitmap bmp) {
			Bitmap bitmap = Bitmap.createBitmap(800, 600, Config.ARGB_8888);
			Canvas canvas = new Canvas(bitmap);
			Bitmap bmps = BitmapFactory.decodeResource(getResources(),
					R.drawable.playerbackground);
			canvas.drawBitmap(bmps, 0, 0, null);
			canvas.drawBitmap(bmp, 10, 100, null);
			canvas.save(Canvas.ALL_SAVE_FLAG);
			canvas.restore();
			File file = new File("/sdcard/wyl/");
			if (!file.exists())
				file.mkdirs();
			try {
				FileOutputStream fileOutputStream = new FileOutputStream(
						file.getPath() + "/wyl.jpg");
				bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
				fileOutputStream.close();
				System.out.println("saveBmp is here");
			} catch (Exception e) {
				Log.e("error", "noSave");
				e.printStackTrace();
			}
		}
	}
//学生成绩管理系统 
	public class MainActivity extends TabActivity {
		private static final String QUERY_TAG = "查询TAG";
		private static final String INSERT_TAG = "添加TAG";
		private static final String UPDATE_TAG = "修改TAG";
		private static final String DELETE_TAG = "删除TAG";
		private TabHost mTabHost;
		private View mViews;
		private EditText mEditText_Name; 
		private EditText mEditText_Number; 
		private EditText mEditText_Score;
		private EditText mEditText_query;
		private Button mButton_query; 
		private Button mButton_insert;
		private ListView query_ListView; 
		private ListView insert_ListView; 
		private SimpleCursorAdapter adapter;
		private MySqliteHelper database;
		private Cursor mCursor;
		private int _id;
		private Cursor mCursor_query;
		private String name, number, score;
		@SuppressWarnings("deprecation")
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			this.setTitle(getResources().getString(R.string.title));
			this.setTitleColor(Color.MAGENTA);
			mTabHost = this.getTabHost();
			mViews = LayoutInflater.from(this).inflate(R.layout.activity_main,
					mTabHost.getTabContentView(), true);
			this.findViewsAndSetListener();
			this.addTabs();
			database = new MySqliteHelper(this);
			showUiAdapter();
		}
		public void addTabs() {
			mTabHost.addTab(mTabHost
					.newTabSpec(QUERY_TAG)
					.setContent(R.id.queryLayout_id)
					.setIndicator(getResources().getString(R.string.query_str),
							getResources().getDrawable(R.drawable.query)));
			mTabHost.addTab(mTabHost
					.newTabSpec(INSERT_TAG)
					.setContent(R.id.insertLayout_id)
					.setIndicator(getResources().getString(R.string.insert_str),
							getResources().getDrawable(R.drawable.add)));
			mTabHost.addTab(mTabHost
					.newTabSpec(UPDATE_TAG)
					.setContent(R.id.insertLayout_id)
					.setIndicator(getResources().getString(R.string.update_str),
							getResources().getDrawable(R.drawable.refresh)));
			mTabHost.addTab(mTabHost
					.newTabSpec(DELETE_TAG)
					.setContent(R.id.insertLayout_id)
					.setIndicator(getResources().getString(R.string.delete_str),
							getResources().getDrawable(R.drawable.delete)));

			mTabHost.setCurrentTab(1);
			mTabHost.setOnTabChangedListener(new OnTabChangeListener() {

				public void onTabChanged(String tabId) {
					if (tabId.equalsIgnoreCase(MainActivity.INSERT_TAG)) {
						mEditText_Name.setEnabled(true);
						mEditText_Number.setEnabled(true);
						mEditText_Score.setEnabled(true);
						mButton_insert.setText(getResources().getString(
								R.string.insert_str));

						State.setSearch(false);
						State.setInsert(true);
						State.setDelete(false);
						setHintText();
						insert_ListView
								.setOnItemClickListener(myOnItemClickListener);
					} else if (tabId.equalsIgnoreCase(MainActivity.UPDATE_TAG)) {
						mEditText_Name.setEnabled(false);
						mEditText_Number.setEnabled(false);
						mEditText_Score.setEnabled(false);
						mButton_insert.setText(getResources().getString(
								R.string.update_str));
						State.setSearch(false);
						State.setInsert(false);
						State.setDelete(false);
						setHintEmptyText();
						insert_ListView
								.setOnItemClickListener(myOnItemClickListener);
					} else if (tabId.equalsIgnoreCase(MainActivity.DELETE_TAG)) {
						mEditText_Name.setEnabled(false);
						mEditText_Number.setEnabled(false);
						mEditText_Score.setEnabled(false);
						mButton_insert.setText(getResources().getString(
								R.string.delete_str));
						State.setSearch(false);
						State.setInsert(false);
						State.setDelete(true);
						setHintEmptyText();
						insert_ListView
								.setOnItemClickListener(myOnItemClickListener);
					} else {
						State.setSearch(true);
						State.setInsert(false);
						State.setDelete(false);
						mEditText_query.setHint(getResources().getString(
								R.string.query_edit_hint));
					}

					Toast.makeText(getApplicationContext(),
							"现在是>>" + tabId + "<<选项", Toast.LENGTH_SHORT).show();
				}
			});
		}
		public void findViewsAndSetListener() {
			EditText editTexts[] = {
					mEditText_Name = (EditText) this
							.findViewById(R.id.insert_editName_id),
					mEditText_Number = (EditText) this
							.findViewById(R.id.insert_editNumber_id),
					mEditText_Score = (EditText) this
							.findViewById(R.id.insert_editScore_id) };
			mEditText_query = (EditText) this.findViewById(R.id.query_edit_id);
			mButton_query = (Button) this.findViewById(R.id.query_button_id);
			mButton_insert = (Button) this.findViewById(R.id.insert_button_id);
			query_ListView = (ListView) this.findViewById(R.id.query_list_id);
			insert_ListView = (ListView) this.findViewById(R.id.insert_list_id);
			mButton_query.setOnClickListener(queryButton_OnClickListener);
			mButton_insert.setOnClickListener(insertButton_OnClickListener);
			for (int i = 0; i < editTexts.length; i++) {
				editTexts[i].setOnClickListener(listener);
			}
			mEditText_query.setOnClickListener(listener);
			mEditText_query.setOnKeyListener(keyListener);
		}
		OnKeyListener keyListener = new OnKeyListener() {
			public boolean onKey(View v, int keyCode, KeyEvent event) {
				if (!mEditText_query.getText().toString().equalsIgnoreCase("")) {
					mButton_query.setEnabled(true);
				} else {
					mButton_query.setEnabled(false);
				}

				return false;
			}

		};
		@SuppressWarnings("deprecation")
		public void showUiAdapter() {
			mCursor = database.searchAllData();
			if (State.isSearch()) {
				mCursor = mCursor_query;
			}
			if (mCursor != null && mCursor.getCount() >= 0) {
				adapter = new SimpleCursorAdapter(this, R.layout.list_item,
						mCursor, new String[] { MySqliteHelper.ID,
								MySqliteHelper.stuName, MySqliteHelper.stuNumber,
								MySqliteHelper.stuScore }, new int[] { R.id.id_id,
								R.id.name_id, R.id.number_id, R.id.score_id });
				if (State.isSearch()) {
					query_ListView.setAdapter(adapter);
				} else {
					insert_ListView.setAdapter(adapter);
				}
			} else {
				Toast.makeText(MainActivity.this, "没有信息!", Toast.LENGTH_SHORT)
						.show();
			}

		}
		public void setHintEmptyText() {
			mEditText_Name.setHint("");
			mEditText_Number.setHint("");
			mEditText_Score.setHint("");

		}
		public void setHintText() {
			mEditText_Name.setHint(getResources().getString(
					R.string.insert_editName_hint));
			mEditText_Number.setHint(getResources().getString(
					R.string.insert_editNumber_hint));
			mEditText_Score.setHint(getResources().getString(
					R.string.insert_editScore_hint));
		}
		OnClickListener queryButton_OnClickListener = new OnClickListener() {
			public void onClick(View v) {
				searchSpecificStuMethod();
			}

		};
		OnClickListener insertButton_OnClickListener = new OnClickListener() {
			public void onClick(View v) {
				if (mButton_insert.getText().equals(
						getResources().getString(R.string.insert_str))) {
					insertMethod();
				} else if (mButton_insert.getText().equals(
						getResources().getString(R.string.update_str))) {
					upDateMethod();
				} else if (mButton_insert.getText().equals(
						getResources().getString(R.string.delete_str))) {
					deleteDataMethod();
				}
			}

		};
		OnClickListener listener = new OnClickListener() {
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.insert_editName_id:
					mEditText_Name.setHint("");
					break;
				case R.id.insert_editNumber_id:
					mEditText_Number.setHint("");
					break;
				case R.id.insert_editScore_id:
					mEditText_Score.setHint("");
					break;
				case R.id.query_edit_id:
					mEditText_query.setHint("");
					break;
				default:
					break;
				}
			}
		};
		OnItemClickListener myOnItemClickListener = new OnItemClickListener() {
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				if (State.isDelete()) {
					mEditText_Name.setEnabled(false);
					mEditText_Number.setEnabled(false);
					mEditText_Score.setEnabled(false);
				} else {
					mEditText_Name.setEnabled(true);
					mEditText_Number.setEnabled(true);
					mEditText_Score.setEnabled(true);
				}
				mCursor.moveToPosition(arg2);
				_id = mCursor.getInt(mCursor.getColumnIndex(MySqliteHelper.ID));
				mEditText_Name.setText(mCursor.getString(mCursor
						.getColumnIndex(MySqliteHelper.stuName)));
				mEditText_Number.setText(mCursor.getString(mCursor
						.getColumnIndex(MySqliteHelper.stuNumber)));
				mEditText_Score.setText(mCursor.getString(mCursor
						.getColumnIndex(MySqliteHelper.stuScore)));
			}

		};
		public void insertMethod() {
			State.setInsert(true);
			if (isValid()) {
				Cursor c = database.isHaveThisStu(Integer.valueOf(number));
				if (c.getCount() > 0 && c != null) {
					Toast.makeText(this,
							getResources().getString(R.string.haveNumber), 1000)
							.show();
				} else {
					database.insertData(name, Integer.valueOf(number),
							Float.valueOf(score));
					update();
				}
			}
		}
		public void update() {
			_id = 0;
			mEditText_Name.setText("");
			mEditText_Number.setText("");
			mEditText_Score.setText("");
			if (State.isUpdataOrDelete()) {
				setHintEmptyText();
			} else {
				setHintText();
			}
			mCursor.requery();
			adapter.notifyDataSetChanged();
			Log.i("//////", "" + State.isInsert());
			if (State.isInsert()) {
				mEditText_Name.setEnabled(true);
				mEditText_Number.setEnabled(true);
				mEditText_Score.setEnabled(true);
			} else {
				mEditText_Name.setEnabled(false);
				mEditText_Number.setEnabled(false);
				mEditText_Score.setEnabled(false);
			}

		}
		public void searchSpecificStuMethod() {
			State.setSearch(true);
			String number = mEditText_query.getText().toString().trim();
			if (number.equalsIgnoreCase("")) {
				return;
			}
			mCursor_query = database.searchSpecific(Integer.valueOf(number));
			if (mCursor_query.getCount() > 0) {
				showUiAdapter();
			} else {
				Toast.makeText(this, getResources().getString(R.string.noinfo),
						Toast.LENGTH_SHORT).show();
			}
			mEditText_query.setHint(getResources().getString(
					R.string.query_edit_hint));

		}
		public boolean isValid() {
			name = null;
			number = null;
			score = null;
			name = mEditText_Name.getText().toString().trim();
			number = mEditText_Number.getText().toString().trim();
			score = mEditText_Score.getText().toString().trim();
			if (name.equalsIgnoreCase("") || number.equalsIgnoreCase("")
					|| score.equalsIgnoreCase("")) {
				Toast.makeText(MainActivity.this, "输入有误,请核对!", Toast.LENGTH_SHORT)
						.show();
				return false;
			} else {
				return true;
			}
		}
		public void upDateMethod() {
			State.setUpdataOrDelete(true);
			if (isValid()) {
				database.upDateinfo(_id, name, Integer.valueOf(number),
						Float.valueOf(score));
			}
			update();

		}
		public void deleteDataMethod() {
			State.setUpdataOrDelete(true);
			if (isValid()) {
				database.deleteStuInfo(_id);
			}
			update();
			mEditText_Name.setEnabled(false);
			mEditText_Number.setEnabled(false);
			mEditText_Score.setEnabled(false);
		}
		@Override
		public boolean onKeyDown(int keyCode, KeyEvent event) {
			if (keyCode == KeyEvent.KEYCODE_BACK) {// 退出键
				this.exitDailog();
			}
			return super.onKeyDown(keyCode, event);
		}
		public void exitDailog() {
			new AlertDialog.Builder(this)
					.setTitle(getResources().getString(R.string.dialog_title))
					.setMessage(getResources().getString(R.string.app_exit))
					.setPositiveButton(getResources().getString(R.string.ok),
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int which) {
									dialog.dismiss();
									database.close();
									finish();
								}
							})
					.setNegativeButton(getResources().getString(R.string.cancle),
							new DialogInterface.OnClickListener() {

								public void onClick(DialogInterface dialog,
										int which) {
									dialog.dismiss();
								}
							}).show();
		}
	}
	public class MySqliteHelper extends SQLiteOpenHelper {
		private static final String DATABASE_NAME = "stu_db";// 数据库的名字
		private static final int DATABASEVERSION = 1;// 版本号
		private static final String TABLE_NAME = "stu_table";// 表名

		private SQLiteDatabase db;// 数据库
		private static final String TAG = "MyDataBase";

		// 4个字段
		public static final String ID = "_id";
		public static final String stuName = "stu_name";
		public static final String stuNumber = "stu_number";
		public static final String stuScore = "stu_score";

		public MySqliteHelper(Context context) {
			// TODO Auto-generated constructor stub
			super(context, DATABASE_NAME, null, DATABASEVERSION);
			// 打开或新建数据库(第一次时创建)获得SQLiteDatabase对象,为了读取和写入数据
			db = this.getWritableDatabase();
		}

		@Override
		public void onCreate(SQLiteDatabase db) {
			// TODO Auto-generated method stub
			Log.i(TAG, "onCreate()");
			// 创建表的sql语句
			String sql = "CREATE TABLE " + TABLE_NAME + " (" + ID
					+ " INTEGER PRIMARY KEY AUTOINCREMENT," + stuName + " TEXT,"
					+ stuNumber + " INTEGER," + stuScore + " FLOAT)";
			db.execSQL(sql);

		}
	   //更新数据库
		@Override
		public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
			// TODO Auto-generated method stub
			Log.i(TAG, " onUpgrade() ");
			// 删除表的SQL
			String sql = "DROP TABLE IF EXITS " + TABLE_NAME;
			db.execSQL(sql);
			onCreate(db);
		}
	   //关闭数据库
		@Override
		public synchronized void close() {
			// TODO Auto-generated method stub
			Log.i(TAG, "close()");
			//关闭数据库
			db.close();
			super.close();
		}
		
		// 查询所有的数据 ,返回Cursor对象(按照id的升序排列)
		public Cursor searchAllData()
		{
			Log.i(TAG, " searchAllData()");
			//数据查询
			//asc是升序desc为降序(默认为asc)
			return db.query(TABLE_NAME, null, null, null, null, null,MySqliteHelper.ID+" ASC" );
		}
		//插入数据
		public void  insertData(String name,int number,float score )
		{
			//在数据库中插入记录
			ContentValues values=new ContentValues();
			values.put(MySqliteHelper.stuName, name);
			values.put(MySqliteHelper.stuNumber, number);
			values.put(MySqliteHelper.stuScore, score);
			long row=db.insert(TABLE_NAME, null, values);
			Log.i(TAG, "insertData row="+row);
		}
		//查询指定的信息
		public Cursor searchSpecific(int number)
		{
			//按条件查询
			 String[] columns={
					 MySqliteHelper.ID,
					 MySqliteHelper.stuName,
					 MySqliteHelper.stuNumber,
					 MySqliteHelper.stuScore
			 };
			
			Cursor cur=db.query(TABLE_NAME, columns,  MySqliteHelper.stuNumber+"="+number, null, null, null, null);
			Log.i("searchSpecific()", " cur.getCount()="+cur.getCount());
			return cur;
		}
		//修改数据
		public void upDateinfo(int id ,String name,int number,float score )
		{
			//修改数据库中的某条记录
			ContentValues values=new ContentValues();
			values.put(MySqliteHelper.stuName, name);
			values.put(MySqliteHelper.stuNumber, number);
			values.put(MySqliteHelper.stuScore, score);
			String whereClause=MySqliteHelper.ID+" = ? ";
			String whereArgs[]={Integer.toString(id)};
			
			int rowaffected =db.update(TABLE_NAME, values, whereClause, whereArgs);
			Log.i(TAG, "upDateinfo()  rowaffected="+rowaffected);
		}
		
		//删除数据
		public void deleteStuInfo(int id)
		{
			int rowaffected =db.delete(TABLE_NAME, MySqliteHelper.ID+"="+id, null);
			Log.i(TAG, "deleteStuInfo()  rowaffected="+rowaffected);
		}
		//判断是否存在改学生的信息
		public Cursor isHaveThisStu(int number)
		{
			 String[] columns={
					 MySqliteHelper.ID,
					 MySqliteHelper.stuName,
					 MySqliteHelper.stuNumber,
					 MySqliteHelper.stuScore
			 };
			
			Cursor cur=db.query(TABLE_NAME, columns,  MySqliteHelper.stuNumber+"="+number, null, null, null, null);
			Log.i("isHaveThisStu()", " cur.getCount()="+cur.getCount());
			return cur;
		}
	}
	public class State {
		public static boolean isSearch = false;
		public static boolean isInsert = false;
		public static boolean isUpdataOrDelete = false;
		public static boolean isDelete = false;
		public static boolean isSearch() {
			return isSearch;
		}
		public static void setSearch(boolean isSearch) {
			State.isSearch = isSearch;
		}
		public static boolean isInsert() {
			return isInsert;
		}
		public static void setInsert(boolean isInsert) {
			State.isInsert = isInsert;
		}
		public static boolean isUpdataOrDelete() {
			return isUpdataOrDelete;
		}
		public static void setUpdataOrDelete(boolean isUpdataOrDelete) {
			State.isUpdataOrDelete = isUpdataOrDelete;
		}
		public static boolean isDelete() {
			return isDelete;
		}
		public static void setDelete(boolean isDelete) {
			State.isDelete = isDelete;
		}
	}
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
		<TextView
			android:id="@+id/id_id"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:textSize="17sp" />
		<TextView
			android:id="@+id/name_id"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
		   android:layout_marginLeft="60sp"
			android:layout_toRightOf="@+id/id_id"
			android:textSize="15sp" />
		<TextView
			android:id="@+id/number_id"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			 android:layout_marginLeft="180sp"
			android:textSize="15sp" />
		<TextView
			android:id="@+id/score_id"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_alignParentRight="true"
			android:layout_marginRight="20sp"
			android:textSize="17sp" />
	</RelativeLayout>
	<FrameLayout 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" >
		<RelativeLayout
			android:id="@+id/queryLayout_id"
			android:layout_width="match_parent"
			android:layout_height="match_parent" >
			<TextView
				android:id="@+id/query_id"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_alignParentLeft="true"
				android:layout_marginTop="25sp"
				android:text="@string/str_id"
				android:textSize="20sp" />
			<EditText
				android:id="@+id/query_edit_id"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_alignBaseline="@+id/query_id"
				android:layout_toRightOf="@+id/query_id"
				android:hint="@string/query_edit_hint"
				android:inputType="number"
				android:lines="1"
				android:singleLine="true"
				android:textColor="@drawable/blue" />
			<Button
				android:id="@+id/query_button_id"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_alignParentRight="true"
				android:layout_below="@+id/query_edit_id"
				android:layout_marginTop="30sp"
				android:enabled="false"
				android:text="@string/str_query_button" />
			<RelativeLayout
				android:id="@+id/layoutColumn_id"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_below="@+id/query_button_id" >
				<TextView
					android:id="@+id/textView1_id"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_alignParentLeft="true"
					android:text="@string/text1"
					android:textSize="20sp" />
				<TextView
					android:id="@+id/textView2_id"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_marginLeft="80sp"
					android:layout_toRightOf="@+id/textView1_id"
					android:text="@string/text2"
					android:textSize="20sp" />
				<TextView
					android:id="@+id/textView3_id"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_marginLeft="180sp"
					android:text="@string/text3"
					android:textSize="20sp" />
				<TextView
					android:id="@+id/textView4_id"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_alignParentRight="true"
					android:layout_marginRight="20sp"
					android:text="@string/text4"
					android:textSize="20sp" />
			</RelativeLayout>
			<ListView
				android:id="@+id/query_list_id"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_below="@+id/layoutColumn_id"
				android:choiceMode="singleChoice" >
			</ListView>
		</RelativeLayout>
		<RelativeLayout
			android:id="@+id/insertLayout_id"
			android:layout_width="match_parent"
			android:layout_height="match_parent" >
			<TextView
				android:id="@+id/insert_textView1_id"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_alignParentLeft="true"
				android:layout_marginTop="25sp"
				android:text="@string/insert_text1"
				android:textSize="20sp" />

			<EditText
				android:id="@+id/insert_editName_id"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_alignBaseline="@+id/insert_textView1_id"
				android:layout_marginTop="22sp"
				android:layout_toRightOf="@+id/insert_textView1_id"
				android:hint="@string/insert_editName_hint"
				android:inputType="text"
				android:lines="1"
				android:singleLine="true" />

			<TextView
				android:id="@+id/insert_textView2_id"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_alignParentLeft="true"
				android:layout_below="@+id/insert_editName_id"
				android:text="@string/insert_text2"
				android:textSize="20sp" />

			<EditText
				android:id="@+id/insert_editNumber_id"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_alignBaseline="@+id/insert_textView2_id"
				android:layout_below="@+id/insert_editName_id"
				android:layout_toRightOf="@+id/insert_textView2_id"
				android:hint="@string/insert_editNumber_hint"
				android:inputType="number"
				android:lines="1"
				android:singleLine="true" />

			<TextView
				android:id="@+id/insert_textView3_id"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_alignParentLeft="true"
				android:layout_below="@+id/insert_editNumber_id"
				android:text="@string/insert_text3"
				android:textSize="20sp" />

			<EditText
				android:id="@+id/insert_editScore_id"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_alignBaseline="@+id/insert_textView3_id"
				android:layout_below="@+id/insert_editNumber_id"
				android:layout_toRightOf="@+id/insert_textView3_id"
				android:hint="@string/insert_editScore_hint"
				android:inputType="numberDecimal"
				android:lines="1"
				android:singleLine="true" />

			<Button
				android:id="@+id/insert_button_id"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_alignParentRight="true"
				android:layout_below="@+id/insert_editScore_id"
				android:text="@string/insert_str" />

			<RelativeLayout
				android:id="@+id/insert_layoutColumn_id"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_below="@+id/insert_button_id" >

				<TextView
					android:id="@+id/insert_textView01_id"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_alignParentLeft="true"
					android:text="@string/text1"
					android:textSize="20sp" />

				<TextView
					android:id="@+id/insert_textView02_id"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_marginLeft="60sp"
					android:layout_toRightOf="@+id/insert_textView01_id"
					android:text="@string/text2"
					android:textSize="20sp" />

				<TextView
					android:id="@+id/insert_textView03_id"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_marginLeft="180sp"
					android:text="@string/text3"
					android:textSize="20sp" />

				<TextView
					android:id="@+id/insert_textView04_id"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_alignParentRight="true"
					android:layout_marginRight="20sp"
					android:text="@string/text4"
					android:textSize="20sp" />
			</RelativeLayout>
			<ListView
				android:id="@+id/insert_list_id"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_below="@+id/insert_layoutColumn_id"
				android:choiceMode="singleChoice" >
			</ListView>
		</RelativeLayout>
	</FrameLayout>
	<resources>
		<string name="app_name">Example06_06</string>
		<string name="action_settings">Settings</string>
		<string name="title">学生成绩管理系统</string>
		<string name="hello_world">Hello world!</string>
		<string name="menu_about">关于本程序</string>
		<string name="title_activity_sqlite_demo">SQliteDemo</string>
		<string name="str_id">学号:</string>
		<string name="query_edit_hint">请输入学生学号</string>
		<string name="str_query_button">查询</string>
		<string name="query_str">查询</string>
		<string name="insert_str">添加</string>
		<string name="update_str">修改</string>
		<string name="delete_str">删除</string>
		<string name="text1">ID</string>
		<string name="text2">姓名</string>
		<string name="text3">学号</string>
		<string name="text4">成绩</string>
		<string name="insert_text1">姓名:</string>
		<string name="insert_text2">学号:</string>
		<string name="insert_text3">成绩:</string>
		<string name="insert_editName_hint">请输入学生姓名</string>
		<string name="insert_editNumber_hint">请输入学生学号</string>
		<string name="insert_editScore_hint">请输入学生成绩</string>
		<string name="noinfo">没有该学生的信息</string>
		<string name="haveNumber">已经存在该学号,请重新输入!</string>
		<string name="dialog_title">温馨提示</string>
		<string name="ok">确定</string>
		<string name="cancle">取消</string>
		<string name="app_exit">你确定退出吗?</string>
	</resources>
Android中的ContentProvider 
//音乐播放器 
	public class MainActivity extends Activity implements OnClickListener {
		private Button mBtnPrevious; 
		private Button mBtnPlay; 
		private Button mBtnNext; 
		private Button mBtnPause;
		private ComponentName component; 

		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			component = new ComponentName(this, MusicService.class);
			mBtnPrevious = (Button) findViewById(R.id.previous);
			mBtnPlay = (Button) findViewById(R.id.play);
			mBtnNext = (Button) findViewById(R.id.next);
			mBtnPause = (Button) findViewById(R.id.pause);
		}
		private void setListener() {
			mBtnPrevious.setOnClickListener(this);
			mBtnPlay.setOnClickListener(this);
			mBtnNext.setOnClickListener(this);
			mBtnPause.setOnClickListener(this);
		}
		public void onClick(View v) {
			if (v == mBtnPrevious) {
				Intent mIntent = new Intent(MusicService.PREVIOUS_ACTION);
				mIntent.setComponent(component);
				startService(mIntent);
			} else if (v == mBtnPlay) {
				Intent mIntent = new Intent(MusicService.PLAY_ACTION);
				mIntent.setComponent(component);
				startService(mIntent);
			} else if (v == mBtnNext) {
				Intent mIntent = new Intent(MusicService.NEXT_ACTION);
				mIntent.setComponent(component);
				startService(mIntent);
			} else {
				Intent mIntent = new Intent(MusicService.PAUSE_ACTION);
				mIntent.setComponent(component);
				startService(mIntent);
			}
		}
	}
	public class MusicService extends Service {
		String[] mCursorCols = new String[] {
				"audio._id AS _id",
				MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.ALBUM,
				MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DATA,
				MediaStore.Audio.Media.MIME_TYPE, MediaStore.Audio.Media.ALBUM_ID,
				MediaStore.Audio.Media.ARTIST_ID, MediaStore.Audio.Media.DURATION };
		private MediaPlayer mMediaPlayer; 
		private Cursor mCursor; 
		private int mPlayPosition = 0;
		public static final String PLAY_ACTION = "com.wyl.music.PLAY_ACTION";
		public static final String PAUSE_ACTION = "com.wyl.music.PAUSE_ACTION";
		public static final String NEXT_ACTION = "com.wyl.music.NEXT_ACTION";
		public static final String PREVIOUS_ACTION = "com.wyl.music.PREVIOUS_ACTION";
		@Override
		public IBinder onBind(Intent arg0) {
			return null;
		}
		@Override
		public void onCreate() {
			super.onCreate();
			mMediaPlayer = new MediaPlayer();
			Uri MUSIC_URL = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
			mCursor = getContentResolver().query(MUSIC_URL, mCursorCols,
					"duration > 10000", null, null);
		}

		@Override
		public void onStart(Intent intent, int startId) {
			super.onStart(intent, startId);
			String action = intent.getAction();
			if (action.equals(PLAY_ACTION)) {
				play();
			} else if (action.equals(PAUSE_ACTION)) {
				pause();
			} else if (action.equals(NEXT_ACTION)) {
				next();
			} else if (action.equals(PREVIOUS_ACTION)) {
				previous();
			}
		}
		public void play() {
			inite();
		}
		public void pause() {
			stopSelf();
		}
		public void previous() {
			if (mPlayPosition == 0) {
				mPlayPosition = mCursor.getCount() - 1;
			} else {
				mPlayPosition--;
			}
			inite();
		}
		public void next() {
			if (mPlayPosition == mCursor.getCount() - 1) {
				mPlayPosition = 0;
			} else {
				mPlayPosition++;
			}
			inite();
		}
		public void inite() {
			mMediaPlayer.reset();
			String dataSource = getDateByPosition(mCursor, mPlayPosition);
			String info = getInfoByPosition(mCursor, mPlayPosition);
			Toast.makeText(getApplicationContext(), info, Toast.LENGTH_SHORT)
					.show();
			try {
				mMediaPlayer.setDataSource(dataSource);
				mMediaPlayer.prepare();
				mMediaPlayer.start();
			} catch (IllegalArgumentException e1) {
				e1.printStackTrace();
			} catch (IllegalStateException e1) {
				e1.printStackTrace();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
		public String getDateByPosition(Cursor c, int position) {
			c.moveToPosition(position);
			int dataColumn = c.getColumnIndex(MediaStore.Audio.Media.DATA);
			String data = c.getString(dataColumn);
			return data;
		}
		public String getInfoByPosition(Cursor c, int position) {
			c.moveToPosition(position);
			int titleColumn = c.getColumnIndex(MediaStore.Audio.Media.TITLE);
			int artistColumn = c.getColumnIndex(MediaStore.Audio.Media.ARTIST);
			String info = c.getString(artistColumn) + " "
					+ c.getString(titleColumn);
			return info;

		}
		public void onDestroy() {
			super.onDestroy();
			mMediaPlayer.release();
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="wyl music player" />
		<LinearLayout
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:orientation="horizontal" >
			<Button
				android:id="@+id/previous"
				android:layout_width="wrap_content"
				android:layout_height="fill_parent"
				android:layout_weight="1"
				android:text="上一首" />
			<Button
				android:id="@+id/play"
				android:layout_width="wrap_content"
				android:layout_height="fill_parent"
				android:layout_weight="1"
				android:text="播放" />
			<Button
				android:id="@+id/next"
				android:layout_width="wrap_content"
				android:layout_height="fill_parent"
				android:layout_weight="1"
				android:text="下一首" />
			<Button
				android:id="@+id/pause"
				android:layout_width="wrap_content"
				android:layout_height="fill_parent"
				android:layout_weight="1"
				android:text="暂停" />
		</LinearLayout>
	</LinearLayout>
//系统图片选择预览 
	public class MainActivity extends Activity {
		private static int RESULT_LOAD_IMAGE = 1;
		private Button BtnLoadImage;
		private ImageView IvLoadImage;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			BtnLoadImage = (Button) findViewById(R.id.buttonLoadPicture);
			IvLoadImage = (ImageView) findViewById(R.id.imgView);
		}
		private void setListener() {
			BtnLoadImage.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View arg0) {
					Intent i = new Intent(
							Intent.ACTION_PICK,
							android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
					startActivityForResult(i, RESULT_LOAD_IMAGE);
				}
			});

		}
		@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			super.onActivityResult(requestCode, resultCode, data);
			if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK
					&& null != data) {
				Uri selectedImage = data.getData();
				String[] filePathColumn = { MediaStore.Images.Media.DATA };
				Cursor cursor = getContentResolver().query(selectedImage,
						filePathColumn, null, null, null);
				cursor.moveToFirst();
				int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
				String picturePath = cursor.getString(columnIndex);
				cursor.close();
				IvLoadImage.setImageBitmap(BitmapFactory.decodeFile(picturePath));
			}
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<ImageView
			android:id="@+id/imgView"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:layout_weight="1" >
		</ImageView>
		<Button
			android:id="@+id/buttonLoadPicture"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_gravity="center"
			android:layout_weight="0"
			android:text="选择图片" >
		</Button>
	</LinearLayout>
//系统的联系人 
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<ListView
			android:id="@+id/Lv_show"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:layout_alignParentTop="true"
			android:visibility="gone" >
		</ListView>
		<LinearLayout
			android:id="@+id/Llay_progressBar"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_alignParentBottom="true"
			android:layout_centerHorizontal="true" >
			<ProgressBar
				android:id="@+id/progressBar1"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content" />
			<TextView
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:paddingTop="20dp"
				android:text="加载中..." />
		</LinearLayout>
	</RelativeLayout>
	public class MainActivity extends Activity {
		private static final String TAG = "MainActivity";
		private List<String> data = new ArrayList<String>();
		private ListView mLvShow; 
		private LinearLayout mLlay_progressBar; 
		Handler mHandler = new Handler() {
			public void handleMessage(Message msg) {
				mLlay_progressBar.setVisibility(View.GONE);
				mLvShow.setAdapter(new ArrayAdapter<String>(MainActivity.this,
						android.R.layout.simple_list_item_1, data));
				mLvShow.setVisibility(View.VISIBLE);
			}
		};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			new Thread(new myRunnable()).start();
		}
		private void findView() {
			mLvShow = (ListView) findViewById(R.id.Lv_show);
			mLlay_progressBar = (LinearLayout) findViewById(R.id.Llay_progressBar);
			mLlay_progressBar.setVisibility(View.VISIBLE);
		}
		private void getContacts() {
			ContentResolver cr = this.getContentResolver();
			Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
					null, null, null);
			while (cursor.moveToNext()) {
				StringBuilder sbLog = new StringBuilder();
				int nameIndex = cursor
						.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
				String name = cursor.getString(nameIndex);
				sbLog.append(name + ":");
				String contactId = cursor.getString(cursor
						.getColumnIndex(ContactsContract.Contacts._ID));
				Cursor phoneNumbers = cr.query(
						ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
						ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = "
								+ contactId, null, null);
				while (phoneNumbers.moveToNext()) {
					String strPhoneNumber = phoneNumbers
							.getString(phoneNumbers
									.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
					sbLog.append(strPhoneNumber + ";");
				}
				phoneNumbers.close();
				Cursor emails = cr.query(
						ContactsContract.CommonDataKinds.Email.CONTENT_URI, null,
						ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = "
								+ contactId, null, null);
				while (emails.moveToNext()) {
					String strEmail = emails
							.getString(emails
									.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
					sbLog.append("Email=" + strEmail + ";");
				}
				emails.close();
				Log.e(TAG, sbLog.toString());
				data.add(sbLog.toString());
			}
			cursor.close();
		}
		class myRunnable implements Runnable {
			public void run() {
				Message message = new Message();
				getContacts();
				mHandler.sendMessage(message);
			}
		}
	}
//得到系统的音频文件 
	public class MainActivity extends Activity {
		private ListView mLvShow;
		private LinearLayout mLlay_progressBar; 
		private List<String> data = new ArrayList<String>(); 
		Handler mHandler = new Handler() {
			public void handleMessage(Message msg) {
				mLlay_progressBar.setVisibility(View.GONE);
				mLvShow.setAdapter(new ArrayAdapter<String>(MainActivity.this,
						android.R.layout.simple_list_item_1, data));
				mLvShow.setVisibility(View.VISIBLE);
			}
		};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			new Thread(new myRunnable()).start();
		}
		private void findView() {
			mLvShow = (ListView) findViewById(R.id.Lv_show);
			mLlay_progressBar = (LinearLayout) findViewById(R.id.Llay_progressBar);
			mLlay_progressBar.setVisibility(View.VISIBLE);
		}
		private void getData() {
			ContentResolver cr = getContentResolver();
			Uri AUDIO_URI = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
			String[] columns = new String[] { MediaStore.Audio.Media.TITLE,
					MediaStore.Audio.Media.DATA };
			Cursor cursor = cr.query(AUDIO_URI, columns,
					MediaStore.Audio.Media.DURATION + ">?",
					new String[] { "1000" }, null);
			Log.e("cursor", cursor.getCount()+"");
			while (cursor.moveToNext()) {
				Log.e("ContentProvider的使用 读取手机内音频 视频 图片文件", cursor.getString(1));
				data.add(cursor.getString(1));
			}
			cursor.close();
		}
		class myRunnable implements Runnable {
			public void run() {
				Message message = new Message();
				getData();
				mHandler.sendMessage(message);
			}
		}
	}
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<ListView
			android:id="@+id/Lv_show"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:layout_alignParentTop="true"
			android:visibility="gone" >
		</ListView>
		<LinearLayout
			android:id="@+id/Llay_progressBar"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_centerInParent="true" >
			<ProgressBar
				android:id="@+id/progressBar"
				style="?android:attr/progressBarStyleLarge"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content" />
		</LinearLayout>
	</RelativeLayout>
Android中的资源文件 
//全屏界面 
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			requestWindowFeature(Window.FEATURE_NO_TITLE);
			getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
			WindowManager.LayoutParams.FLAG_FULLSCREEN);
			setContentView(R.layout.activity_main);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<TextView 
			android:text="我是全屏效果"
			android:gravity="center"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:textSize="30sp"
			/>
	</LinearLayout>
//小图堆积背景 
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/MainLayout"
	android:layout_width="fill_parent"
	android:layout_height="fill_parent"
	android:orientation="vertical"
	android:background="@drawable/backrepeat">
	</LinearLayout>
//自定义EditText样式 
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<EditText
			android:id="@+id/et1"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="默认样式" >
		</EditText>
		<EditText
			android:id="@+id/et2"
			style="@style/et1"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="自定义样式一" >
		</EditText>
		<EditText
			android:id="@+id/et3"
			style="@style/et2"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="自定义样式二" >
		</EditText>
	</LinearLayout>
//透明背景的Activity 
	public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<TextView 
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:text="在Manifest中设置Activity theme 为Theme.Translucent使Activity背景透明"
			android:textSize="20sp"
			android:textColor="@android:color/widget_edittext_dark"
			/>
	</LinearLayout>
//圆角控件的制作 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<ListView 
			android:layout_margin="10dp"
			android:id="@+id/lv_show"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:background="@drawable/list_bg"
			></ListView>
	</LinearLayout>
	public class MainActivity extends Activity {
		private ListView mLvShow;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
		}
		private void findView() {
			mLvShow = (ListView) findViewById(R.id.lv_show);
			mLvShow.setAdapter(new ArrayAdapter<String>(this,
					android.R.layout.simple_expandable_list_item_1, getData()));
		}
		private List<String> getData() {
			List<String> data = new ArrayList<String>();
			data.add("圆角背景测试数据1");
			data.add("圆角背景测试数据2");
			data.add("圆角背景测试数据3");
			data.add("圆角背景测试数据4");
			return data;
		}
	}
//程序的国际化 
		public class MainActivity extends Activity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			Button b;
			b = (Button) findViewById(R.id.flag_button);
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setMessage(R.string.dialog_text)
					.setCancelable(false)
					.setTitle(R.string.dialog_title)
					.setPositiveButton(R.string.dialog_ok,
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog, int id) {
									dialog.dismiss();
								}
							});

			final AlertDialog alert = builder.create();
			b.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					alert.show();
				}
			});
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:gravity="center_horizontal"
			android:textSize="30sp"
			android:text="@string/text_a" />
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:gravity="center_horizontal"
			android:textSize="30sp"
			android:text="@string/text_b" />
		<Button
			android:id="@+id/flag_button"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:textSize="30sp"
			android:layout_gravity="center" 
			android:text="@string/btn_text"
			/>
	</LinearLayout>
	<resources>
		<string name="app_name">Example06_16</string>
		<string name="action_settings">Settings</string>
		<string name="hello_world">Hello world!</string>
		<string name="text_a">周傑倫</string>
		<string name="text_b">劉德華</string>
		<string name="dialog_ok">確定</string>
		<string name="dialog_title">上傳對話框</string>
		<string name="dialog_text">數據已上傳成功</string>
		<string name="btn_text">上傳</string>
	</resources>
Android中的服务和广播 
Android中的服务的使用 
//查看手机运行的进程列表 
	public class MainActivity extends Activity {
		private Button btnEnableMember;
		private Button btnLookRuningMemory;
		private ActivityManager mActivityManager;
		private TextView tvText;
		private ListView listviewProcess;
		private ArrayList<ProcessInfo> processInfoList;
		private TextView tvCurrentProcessNum;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
			mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
		}
		private void setListener() {
			btnEnableMember.setOnClickListener(listener);
			btnLookRuningMemory.setOnClickListener(listener);
		}
		private void findView() {
			btnEnableMember = (Button) findViewById(R.id.btn_main_ablememory);
			btnLookRuningMemory = (Button) findViewById(R.id.btn_main_lookruningmemory);
			tvText = (TextView) findViewById(R.id.tv_main_text);
			listviewProcess = (ListView) findViewById(R.id.lv_main_list);
			tvCurrentProcessNum = (TextView) findViewById(R.id.tv_main_currentprocessnum);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_main_ablememory:
					String availMemStr = getSystemAvaialbeMemorySize();
					tvText.setText(availMemStr);
					tvText.setVisibility(View.VISIBLE);
					listviewProcess.setVisibility(View.GONE);
					break;
				case R.id.btn_main_lookruningmemory:
					tvText.setVisibility(View.GONE);
					listviewProcess.setVisibility(View.VISIBLE);
					getRunningAppProcessInfo();
					setAdapter();
					break;
				default:
					break;
				}

			}
		};
		protected String getSystemAvaialbeMemorySize() {
			MemoryInfo memoryInfo = new MemoryInfo();
			mActivityManager.getMemoryInfo(memoryInfo);
			long memSize = memoryInfo.availMem;
			String availMemStr = formateFileSize(memSize);
			return availMemStr;
		}
		private String formateFileSize(long size) {
			return Formatter.formatFileSize(MainActivity.this, size);
		}
		protected void setAdapter() {
			ProcessInfoAdapter mprocessInfoAdapter = new ProcessInfoAdapter(this,
					processInfoList);
			listviewProcess.setAdapter(mprocessInfoAdapter);
		}
		private void getRunningAppProcessInfo() {
			processInfoList = new ArrayList<ProcessInfo>();

			List<ActivityManager.RunningAppProcessInfo> appProcessList = mActivityManager
					.getRunningAppProcesses();

			for (ActivityManager.RunningAppProcessInfo appProcessInfo : appProcessList) {
				int pid = appProcessInfo.pid;
				int uid = appProcessInfo.uid;
				String processName = appProcessInfo.processName;
				int[] myMempid = new int[] { pid };
				Debug.MemoryInfo[] memoryInfo = mActivityManager
						.getProcessMemoryInfo(myMempid);
				int memSize = memoryInfo[0].dalvikPrivateDirty;
				ProcessInfo processInfo = new ProcessInfo();
				processInfo.setPid(pid);
				processInfo.setUid(uid);
				processInfo.setMemSize(memSize);
				processInfo.setProcessName(processName);
				processInfoList.add(processInfo);
			}
			tvCurrentProcessNum.setText("当前系统进程共有:" + processInfoList.size());
		}
	}
	public class ProcessInfo {
		private int pid; 
		private int uid;
		private int memSize;
		private String processName;
		public ProcessInfo(){}
		public int getPid() {
			return pid;
		}
		public void setPid(int pid) {
			this.pid = pid;
		}
		public int getUid() {
			return uid;
		}
		public void setUid(int uid) {
			this.uid = uid;
		}
		public int getMemSize() {
			return memSize;
		}
		public void setMemSize(int memSize) {
			this.memSize = memSize;
		}
		public String getProcessName() {
			return processName;
		}
		public void setProcessName(String processName) {
			this.processName = processName;
		}
	}
	public class ProcessInfoAdapter extends BaseAdapter {
		private List<ProcessInfo> mlistProcessInfo = null;
		LayoutInflater infater = null;
		public ProcessInfoAdapter(Context context, List<ProcessInfo> apps) {
			infater = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			mlistProcessInfo = apps;
		}
		@Override
		public int getCount() {
			System.out.println("size" + mlistProcessInfo.size());
			return mlistProcessInfo.size();
		}
		@Override
		public Object getItem(int position) {
			return mlistProcessInfo.get(position);
		}
		@Override
		public long getItemId(int position) {
			return 0;
		}
		@Override
		public View getView(int position, View convertview, ViewGroup arg2) {
			View view = null;
			ViewHolder holder = null;
			if (convertview == null || convertview.getTag() == null) {
				view = infater.inflate(R.layout.browse_process_item, null);
				holder = new ViewHolder(view);
				view.setTag(holder);
			} else {
				view = convertview;
				holder = (ViewHolder) convertview.getTag();
			}
			ProcessInfo processInfo = (ProcessInfo) getItem(position);
			holder.tvPID.setText(processInfo.getPid() + "");
			holder.tvUID.setText(processInfo.getUid() + "");
			holder.tvProcessMemSize.setText(processInfo.getMemSize() + "KB");
			holder.tvProcessName.setText(processInfo.getProcessName());
			return view;
		}
		class ViewHolder {
			TextView tvPID; 
			TextView tvUID; 
			TextView tvProcessMemSize;
			TextView tvProcessName; 
			public ViewHolder(View view) {
				this.tvPID = (TextView) view.findViewById(R.id.tvProcessPID);
				this.tvUID = (TextView) view.findViewById(R.id.tvProcessUID);
				this.tvProcessMemSize = (TextView) view
						.findViewById(R.id.tvProcessMemSize);
				this.tvProcessName = (TextView) view
						.findViewById(R.id.tvProcessName);
			}
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button 
			android:id="@+id/btn_main_ablememory"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="可用 的内存"/>
		<Button 
			android:id="@+id/btn_main_lookruningmemory"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="查看正在运行的进程"/>
		<TextView
			android:id="@+id/tv_main_currentprocessnum"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content" />
		<ListView 
			android:id="@+id/lv_main_list"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"/>
		<TextView
			 android:id="@+id/tv_main_text"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" />
	</LinearLayout>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="fill_parent" android:layout_height="80dip" android:orientation="vertical">
		<LinearLayout android:layout_width="fill_parent" 
			android:layout_height="wrap_content" android:layout_marginLeft="10dip"
			android:orientation="horizontal">
			<TextView android:layout_width="100dip"
				android:layout_height="wrap_content" android:text="进程ID : "></TextView>
			<TextView android:id="@+id/tvProcessPID"
				android:layout_width="wrap_content" android:layout_height="wrap_content"
				android:layout_marginLeft="3dip" android:textColor="#FFD700"></TextView>
		</LinearLayout>
		<LinearLayout android:layout_width="fill_parent"
			android:layout_height="wrap_content" android:layout_marginLeft="10dip"
			android:orientation="horizontal">
			<TextView android:layout_width="100dip"
				android:layout_height="wrap_content" android:text="进程所在UID:"></TextView>
			<TextView android:id="@+id/tvProcessUID"
				android:layout_width="wrap_content" android:layout_height="wrap_content"
				android:textColor="#FFD700"></TextView>
		</LinearLayout>
		<LinearLayout android:layout_width="fill_parent"
			android:layout_height="wrap_content" android:layout_marginLeft="10dip"
			android:orientation="horizontal">
			<TextView android:layout_width="100dip"
				android:layout_height="wrap_content" android:text="进程占用内存:"></TextView>
			<TextView android:id="@+id/tvProcessMemSize"
				android:layout_width="wrap_content" android:layout_height="wrap_content"
				android:textColor="#FFD700"></TextView>
		</LinearLayout>
		<LinearLayout android:layout_width="fill_parent"
			android:layout_height="wrap_content" android:layout_marginLeft="10dip"
			android:orientation="horizontal">
			<TextView android:layout_width="100dip"
				android:layout_height="wrap_content" android:text="进程名:"></TextView>
			<TextView android:id="@+id/tvProcessName"
				android:layout_width="wrap_content" android:layout_height="wrap_content"
				android:textColor="#FFD700"></TextView>
		</LinearLayout>
	</LinearLayout>
//得到系统的唤醒服务 
	<LinearLayout 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:orientation="vertical" >
		<Button 
			android:id="@+id/BtnGet"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="点击获取唤醒锁"
			/>
		<Button 
			android:id="@+id/BtnRelease"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="点击释放唤醒锁"
			/>
	</LinearLayout>
	public class MainActivity extends Activity {
		private WakeLock wakeLock;
		private Button BtnGet;
		private Button BtnRelease;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			BtnGet.setOnClickListener(mylistener);
			BtnRelease.setOnClickListener(mylistener);
		}
		private void findView() {
			BtnGet = (Button)findViewById(R.id.BtnGet);
			BtnRelease = (Button)findViewById(R.id.BtnRelease);
		}
		OnClickListener mylistener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.BtnGet:
					acquireWakeLock();
					break;
				case R.id.BtnRelease:
					releaseWakeLock();
					break;
				default:
					break;
				}
			}
		};
		private void acquireWakeLock() {
			if (wakeLock == null) {
				Toast.makeText(this, "得到唤醒锁", Toast.LENGTH_SHORT)
						.show();
				PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
				wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, this
						.getClass().getCanonicalName());
				wakeLock.acquire();
			}
		}
		private void releaseWakeLock() {
			if (wakeLock != null && wakeLock.isHeld()) {
				wakeLock.release();
				wakeLock = null;
			}
			Toast.makeText(MainActivity.this, "释放唤醒锁",Toast.LENGTH_SHORT).show();
		}
	}
//定时任务启动 
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/brodcast"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="定时发送广播" />
		<Button
			android:id="@+id/service"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="定时启动服务" />
		<Button
			android:id="@+id/brodcaststop"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="停止定时广播" />
		<Button
			android:id="@+id/servicestop"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="停止定时服务" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button btnBrodcast;
		private Button btnService;
		private AlarmManager am;
		private Button btnBrodcastStop;
		private Button btnServiceStop;
		private PendingIntent pi1;
		private PendingIntent pi2;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			am = (AlarmManager) getSystemService(ALARM_SERVICE);
			findView();
			setListener();
		}
		private void findView() {
			btnBrodcast = (Button) findViewById(R.id.brodcast);
			btnService = (Button) findViewById(R.id.service);
			btnBrodcastStop = (Button) findViewById(R.id.brodcaststop);
			btnServiceStop = (Button) findViewById(R.id.servicestop);
		}
		private void setListener() {
			btnBrodcast.setOnClickListener(listener);
			btnBrodcastStop.setOnClickListener(listener);
			btnService.setOnClickListener(listener);
			btnServiceStop.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.brodcast:
					pi1 = PendingIntent.getBroadcast(MainActivity.this, 0,
							new Intent(MainActivity.this, ActionBroadCast.class),
							Intent.FLAG_ACTIVITY_NEW_TASK);
					long now = System.currentTimeMillis();
					am.setInexactRepeating(AlarmManager.RTC_WAKEUP, now, 3000, pi1);
					break;
				case R.id.brodcaststop:
					am.cancel(pi1);
					break;
				case R.id.service:
					pi2 = PendingIntent.getService(MainActivity.this, 0,
							new Intent(MainActivity.this, ActionService.class),
							Intent.FLAG_ACTIVITY_NEW_TASK);
					long now1 = System.currentTimeMillis();
					am.setInexactRepeating(AlarmManager.RTC_WAKEUP, now1, 3000, pi2);
					break;
				case R.id.servicestop:
					am.cancel(pi2);
					break;
				default:
					break;
				}
			}
		};
	}
	public class ActionService extends Service{
		private static int num = 0;
		@Override
		public IBinder onBind(Intent intent) {
			return null;
		}
		@Override
		public void onCreate() {
			super.onCreate();
			Log.e("ActionService", "New Message !" + num++);
		}
	}
	public class ActionBroadCast extends BroadcastReceiver {
		private static int num = 0;
		@Override
		public void onReceive(Context context, Intent intent) {
			Log.e("ActionBroadCast", "New Message !" + num++);
		}
	}
//发送状态栏信息 
	public class MainActivity extends Activity {
		private Button btnNotification;
		private Notification baseNF;
		private NotificationManager nm;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
			findView();
			setListener();
		}
		private void findView() {
			btnNotification = (Button) findViewById(R.id.show);
		}
		private void setListener() {
			btnNotification.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					setNotification();
				}
			});
		}
		@SuppressWarnings("deprecation")
		protected void setNotification() {
			baseNF = new Notification();
			baseNF.icon = R.drawable.ic_action_search;
			baseNF.tickerText = "I am a notification!";
			baseNF.defaults = Notification.DEFAULT_SOUND;
			PendingIntent pi = PendingIntent.getActivity(MainActivity.this, 0,
					new Intent(this, MainActivity.class), 0);
			baseNF.setLatestEventInfo(MainActivity.this, "Title01", "Content01", pi);
			nm.notify(0, baseNF);
		}
	}
	<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" >
		<Button
			android:id="@+id/show"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="发送状态栏通知" />
	</RelativeLayout>
//得到屏幕状态 
	public class MainActivity extends Activity {
		private Button btnKeyguard;
		private KeyguardManager keyguardManager;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			keyguardManager=(KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
			findView();
			setListener();
		}
		private void findView() {
			btnKeyguard = (Button) findViewById(R.id.reenableKeyguard);
		}
		private void setListener() {
			btnKeyguard.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					if(keyguardManager.isKeyguardLocked())
					{
						Toast.makeText(MainActivity.this, "锁屏", Toast.LENGTH_SHORT).show();
					}
					else
					{
						Toast.makeText(MainActivity.this, "没有锁屏", Toast.LENGTH_SHORT).show();
					}
				}
			});
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/reenableKeyguard"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="屏幕的状态" />
	</LinearLayout>
//程序中得到经纬度 
	public class MainActivity extends Activity {
		private Button btnPosition;
		private LocationManager locationManager;
		private TextView tv;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			locationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
			findView();
			setListener();
		}
		private void findView() {
			btnPosition = (Button) findViewById(R.id.position);
			tv = (TextView) findViewById(R.id.tv);
		}
		private void setListener() {
			locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 10,
							locationListener);
			btnPosition.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					tv.setText("当前的经度是:39.926325,"+"\n当前的纬度是:116.38945");
				}
			});
		}
		private final LocationListener locationListener = new LocationListener() {
			@Override
			public void onStatusChanged(String provider, int status,
					Bundle extras) {
			}
			@Override
			public void onProviderEnabled(String provider) {
			}
			@Override
			public void onProviderDisabled(String provider) {
			}
			@Override
			public void onLocationChanged(Location location) {
				tv.setText("当前的经度是"+location.getLatitude()+"当前的纬度是"+location.getLongitude());
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/position"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="当前的位置" />
		<TextView
			android:id="@+id/tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="" />
	</LinearLayout>
//振动器应用 
	public class MainActivity extends Activity {
		private Button btnStart;
		private Vibrator vibrator;
		private Button btnStop;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			vibrator=(Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
			findView();
			setListener();
		}
		private void findView() {
			btnStart = (Button) findViewById(R.id.start);
			btnStop=(Button)findViewById(R.id.stop);
		}
		private void setListener() {
			btnStart.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					vibrator.vibrate(new long[] {1000,1000,1000}, 0);
				}
			});
			btnStop.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					vibrator.cancel();
				}
			});
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/start"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开始震动" />
		<Button
			android:id="@+id/stop"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="停止震动" />
	</LinearLayout>
//获得当前网络状态 
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_network"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="当前网络状态" />
		<TextView
			android:id="@+id/tv_networkshow"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:textSize="20dp" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button btnNetWork;
		ConnectivityManager connManager ;
		private NetworkInfo networkInfo;
		private TextView tvNetWorkShow;
		private String strNetWork;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			connManager=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
			networkInfo = connManager.getActiveNetworkInfo();  
			findView();
			setListener();
		}
		private void findView() {
			btnNetWork = (Button) findViewById(R.id.btn_network);
			tvNetWorkShow=(TextView)findViewById(R.id.tv_networkshow);
		}
		private void setListener() {
			btnNetWork.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					if(networkInfo.isAvailable())
					{
						strNetWork="当前网络可用\n";
					}
					else{
						strNetWork="当前网络不可用\n";
					}
					State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
					if(state==State.CONNECTED)
					{
						strNetWork+="GPRS网络已连接\n";
					}
					state = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState(); 
					if(state==State.CONNECTED)
					{
						strNetWork+="WIFI网络已连接\n";
					}
					tvNetWorkShow.setText(strNetWork);
				}
			});
		}
	}
//获得手机SIM卡信息 
	public class MainActivity extends Activity {
		private Button btnNetWork;
		private TelephonyManager tm;
		private TextView tvSimInfoShow;
		private String strSimInfo;
		private String [] simState={"状态未知","无SIM卡","别PIN加锁","被PUK加锁","被NetWork PIN加锁","已准备好"};
		private String [] phoneTypes={"未知","GSM","CDMA"};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			tm=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
			findView();
			setListener();
		}
		private void findView() {
			btnNetWork = (Button) findViewById(R.id.btn_siminfo);
			tvSimInfoShow=(TextView)findViewById(R.id.tv_siminfoshow);
		}
		private void setListener() {
			btnNetWork.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					String deviceId=tm.getDeviceId();
					String Country=tm.getSimCountryIso();
					String SIMSerial=tm.getSimSerialNumber();
					String SIMState=simState[tm.getSimState()];
					String networkOperator= tm.getNetworkOperator();
					String networkOperatorName= tm.getNetworkOperatorName();
					String phoneType=phoneTypes[tm.getPhoneType()];
					strSimInfo="设备编号:"+deviceId+"\nSIM卡的国别: "+Country+"\nSIM卡序列号: "+SIMSerial
							+"\nSIM卡状态: "+SIMState+"\n网络运营商代号 : "+networkOperator+"\n网络运营商名称: "+networkOperatorName
							+"\n手机的制式: "+phoneType;
					tvSimInfoShow.setText(strSimInfo);
				};
			});
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_siminfo"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="当前SIM卡信息" />
	   <TextView 
		   android:id="@+id/tv_siminfoshow"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:textSize="20dp"/>
	</LinearLayout>
//WiFi管理器 
	public class MainActivity extends Activity {
		private Button btnOpenWifi;
		private Button btnCloseWifi;
		private Button btnWifiList;
		private WifiManager mWifiManager;
		private List<ScanResult> mWifiList=new ArrayList<ScanResult>();
		private List<String> wifiList=new ArrayList<String>();
		private ListView lvWifiList;
		private TextView tvWifiInfo;
		private Button btnWifiInfo;
		private WifiInfo mWifiInfo;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			mWifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
			mWifiInfo = mWifiManager.getConnectionInfo();  
			findView();
			setListener();
		}

		private void findView() {
			btnOpenWifi = (Button) findViewById(R.id.btn_openwifi);
			btnCloseWifi=(Button)findViewById(R.id.btn_closewifi);
			btnWifiList=(Button)findViewById(R.id.btn_getwifilist);
			btnWifiInfo=(Button)findViewById(R.id.btn_getwifiinfo);
			lvWifiList=(ListView)findViewById(R.id.lv_wifilist);
			tvWifiInfo=(TextView)findViewById(R.id.tv_getwifiinfo);
		}
		private void setListener() {
			btnCloseWifi.setOnClickListener(listener);
			btnOpenWifi.setOnClickListener(listener);
			btnWifiList.setOnClickListener(listener);
			btnWifiInfo.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_openwifi:
					if (!mWifiManager.isWifiEnabled())
					{
						mWifiManager.setWifiEnabled(true);
						Toast.makeText(MainActivity.this, "WIFI已经开启", Toast.LENGTH_SHORT).show();
					}
					break;
				case R.id.btn_closewifi:
					if (mWifiManager.isWifiEnabled())
					{
						mWifiManager.setWifiEnabled(false);	
						Toast.makeText(MainActivity.this, "WIFI已经关闭", Toast.LENGTH_SHORT).show();
					}
					break;
				case R.id.btn_getwifilist:
					if(mWifiManager.isWifiEnabled())
					{
						mWifiManager.startScan();
						mWifiList = mWifiManager.getScanResults();
						for(int i=0;i<mWifiList.size();i++)
						{
							wifiList.add(mWifiList.get(i).SSID);
						}
						setAdapter();
					}
					else{
						Toast.makeText(MainActivity.this, "WIFI没有开启,无法扫描", Toast.LENGTH_SHORT).show();
					}
					break;
				case R.id.btn_getwifiinfo:
					String bssid=mWifiInfo.getBSSID();
					String macAddress=mWifiInfo.getMacAddress();  
					int ipAddress=mWifiInfo.getIpAddress();
					int netWorkId=mWifiInfo.getNetworkId();
					tvWifiInfo.setText("接入点的BSSID :"+bssid+"\nMAC地址 :"+macAddress+"\nIP地址 :"+ipAddress+"\n连接的ID :"+netWorkId);
				default:
					break;
				}
			}
		};
		protected void setAdapter() {
			ArrayAdapter<String> adapter=new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, wifiList);
			lvWifiList.setAdapter(adapter);
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_openwifi"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开启WIFI" />
		<Button
			android:id="@+id/btn_closewifi"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="关闭WIFI" />
		<Button
			android:id="@+id/btn_getwifilist"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="获取WIFI列表" />
		<Button
			android:id="@+id/btn_getwifiinfo"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="得到WIFI信息" />
		<TextView
			android:id="@+id/tv_getwifiinfo"
			android:layout_width="match_parent"
			android:layout_height="wrap_content" />
		<ListView
			android:id="@+id/lv_wifilist"
			android:layout_width="match_parent"
			android:layout_height="wrap_content" />
	</LinearLayout>
//系统软键盘显示 
	public class MainActivity extends Activity {
		private Button btnSoft;
		InputMethodManager imm ;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
			findView();
			setListener();
		}
		private void findView() {
			btnSoft = (Button) findViewById(R.id.btn_soft);
		}
		private void setListener() {
			btnSoft.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_soft"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="弹出/关闭软键盘" />
	</LinearLayout>
//打开系统行车模式 
	public class MainActivity extends Activity {
		private Button btnOpenDriverCar;
		private Button btnCloseDriverCar;
		private Button btnOpenNight;
		private Button btnCloseNight;
		private UiModeManager uiModeManager;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			uiModeManager = (UiModeManager)getSystemService(Context.UI_MODE_SERVICE);
			findView();
			setListener();
		}
		private void findView() {
			btnOpenDriverCar = (Button) findViewById(R.id.btn_opendrivercar);
			btnCloseDriverCar=(Button)findViewById(R.id.btn_closedrivercar);
			btnOpenNight=(Button)findViewById(R.id.btn_opennight);
			btnCloseNight=(Button)findViewById(R.id.btn_closenight);
		}
		private void setListener() {
			btnCloseDriverCar.setOnClickListener(listener);
			btnCloseNight.setOnClickListener(listener);
			btnOpenDriverCar.setOnClickListener(listener);
			btnOpenNight.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_opendrivercar:
					uiModeManager.enableCarMode(UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME);
					Toast.makeText(MainActivity.this, "已经开启行车模式", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_closedrivercar:
					uiModeManager.disableCarMode(UiModeManager.DISABLE_CAR_MODE_GO_HOME);
					Toast.makeText(MainActivity.this, "已经关闭行车模式", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_opennight:
					uiModeManager.setNightMode(UiModeManager.MODE_NIGHT_YES);
					Toast.makeText(MainActivity.this, "已经开启夜间模式", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_closenight:
					uiModeManager.setNightMode(UiModeManager.MODE_NIGHT_NO);
					Toast.makeText(MainActivity.this, "已经关闭夜间模式", Toast.LENGTH_SHORT).show();
					break;
				default:
					break;
				}
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_opendrivercar"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开启行车模式" />
		<Button
			android:id="@+id/btn_closedrivercar"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="关闭行车模式" />
		<Button
			android:id="@+id/btn_opennight"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开启夜间模式" />
		<Button
			android:id="@+id/btn_closenight"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="关闭夜间模式" />
	</LinearLayout>
//音量控制器 
		public class MainActivity extends Activity {
		private Button btnCurrentVolume;
		private Button btnIncreaseVolume;
		private Button btnDeclineVolume;
		private TextView tvVolume;
		private AudioManager audioManager ;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
			findView();
			setListener();
		}
		private void findView() {
			btnCurrentVolume = (Button) findViewById(R.id.btn_currentvolume);
			btnDeclineVolume=(Button)findViewById(R.id.btn_declinevolume);
			btnIncreaseVolume=(Button)findViewById(R.id.btn_increaselvolume);
			tvVolume=(TextView)findViewById(R.id.tv_volumn);
		}
		private void setListener() {
			btnCurrentVolume.setOnClickListener(listener);
			btnDeclineVolume.setOnClickListener(listener);
			btnIncreaseVolume.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_currentvolume:
					int currentCall = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL ); 
					int currentSystem = audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM ); 
					int currentMusic = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC ); 
					int currentTip = audioManager.getStreamVolume(AudioManager.STREAM_ALARM );
					tvVolume.setText("当前的通话音量:"+currentCall+"\n当前的系统音量: "+currentSystem+"\n当前的音乐音量: "+currentMusic+"\n当前的提示声音音量: "+currentTip);
					break;
				case R.id.btn_increaselvolume:
					 audioManager.adjustStreamVolume(AudioManager.STREAM_SYSTEM,
							 AudioManager.ADJUST_RAISE,
							 AudioManager.FX_FOCUS_NAVIGATION_UP);
					break;
				case R.id.btn_declinevolume:
					audioManager.adjustStreamVolume(AudioManager.STREAM_SYSTEM,AudioManager.ADJUST_LOWER,
							AudioManager.FX_FOCUS_NAVIGATION_UP);
					break;
				}
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_currentvolume"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="当前的音量" />
		<Button
			android:id="@+id/btn_increaselvolume"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="增大系统音量" />
		<Button
			android:id="@+id/btn_declinevolume"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="减小系统音量" />
		<TextView
			android:id="@+id/tv_volumn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content" />
	</LinearLayout>
//短信群发软件 
	public class MainActivity extends Activity {
		String SENT_SMS_ACTION = "SENT_SMS_ACTION";
		private EditText edit_no;
		private EditText edit_body;
		private Button button;
		private String body;
		private String[] address; 
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			edit_no = (EditText) findViewById(R.id.et_number);
			edit_body = (EditText) findViewById(R.id.et_body);
			button = (Button) findViewById(R.id.btn_send);
		}
		private void setListener() {
			button.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					String p = edit_no.getText().toString();
					body = edit_body.getText().toString();
					address = p.split(",");
					Set<String> addr = new HashSet<String>();
					for (int i = 0; i < address.length; i++) {
						addr.add(address[i]);
					}
					sendSMS(addr, body);
					edit_no.setText("");
					edit_body.setText("");
				}
			});
		}
		public void sendSMS(Set<String> phone, String body) {
			SmsManager msg = SmsManager.getDefault();
			Intent send = new Intent(SENT_SMS_ACTION);
			PendingIntent sendPI = PendingIntent.getBroadcast(this, 0, send, 0);
			for (String pno : phone) {
				msg.sendTextMessage(pno, null, body, sendPI, null);
			}

		}
		protected void onResume() {
			super.onResume();
			registerReceiver(sendMessage, new IntentFilter(SENT_SMS_ACTION));
		}
		BroadcastReceiver sendMessage = new BroadcastReceiver() {
			@Override
			public void onReceive(Context c, Intent intent) {
				switch (getResultCode()) {
				case Activity.RESULT_OK:
					Toast.makeText(MainActivity.this, "发送成功!",
							Toast.LENGTH_SHORT)
							.show();
					break;
				default:
					Toast.makeText(MainActivity.this, "发送失败!",
							Toast.LENGTH_SHORT)
							.show();
					break;
				}
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<EditText
			android:id="@+id/et_number"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="号码" />
		 <EditText
			android:id="@+id/et_body"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:hint="内容" />
		  <Button
			android:id="@+id/btn_send"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="发送" />
	</LinearLayout>
//电池状态查看器 
	public class MainActivity extends Activity {
		private Button btnBattery;
		private TextView tvBattery;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			btnBattery = (Button) findViewById(R.id.btn_battery);
			tvBattery = (TextView) findViewById(R.id.tv_battery);
		}
		private void setListener() {
			btnBattery.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_battery:
					IntentFilter filter = new IntentFilter();
					filter.addAction(Intent.ACTION_BATTERY_CHANGED);
					registerReceiver(mBroadcastReceiver, filter);
					break;
				}
			}
		};
		private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
			@Override
			public void onReceive(Context context, Intent intent) {
				String action = intent.getAction();
				if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
					int status = intent.getIntExtra("status", 0);
					int health = intent.getIntExtra("health", 0);
					boolean present = intent.getBooleanExtra("present", false);
					int level = intent.getIntExtra("level", 0);
					int scale = intent.getIntExtra("scale", 0);
					int icon_small = intent.getIntExtra("icon-small", 0);
					int plugged = intent.getIntExtra("plugged", 0);
					int voltage = intent.getIntExtra("voltage", 0);
					int temperature = intent.getIntExtra("temperature", 0);
					String technology = intent.getStringExtra("technology");
					String statusString = "";
					switch (status) {
					case BatteryManager.BATTERY_STATUS_UNKNOWN:
						statusString = "unknown";
						break;
					case BatteryManager.BATTERY_STATUS_CHARGING:
						statusString = "charging";
						break;
					case BatteryManager.BATTERY_STATUS_DISCHARGING:
						statusString = "discharging";
						break;
					case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
						statusString = "not charging";
						break;
					case BatteryManager.BATTERY_STATUS_FULL:
						statusString = "full";
						break;
					}
					String healthString = "";
					switch (health) {
					case BatteryManager.BATTERY_HEALTH_UNKNOWN:
						healthString = "unknown";
						break;
					case BatteryManager.BATTERY_HEALTH_GOOD:
						healthString = "good";
						break;
					case BatteryManager.BATTERY_HEALTH_OVERHEAT:
						healthString = "overheat";
						break;
					case BatteryManager.BATTERY_HEALTH_DEAD:
						healthString = "dead";
						break;
					case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
						healthString = "voltage";
						break;
					case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
						healthString = "unspecified failure";
						break;
					}
					String acString = "";
					switch (plugged) {
					case BatteryManager.BATTERY_PLUGGED_AC:
						acString = "plugged ac";
						break;
					case BatteryManager.BATTERY_PLUGGED_USB:
						acString = "plugged usb";
						break;
					}
					tvBattery.setText("电池的状态:" + statusString
							+ "\n健康值: "+ healthString 
							+ "\n电池剩余容量: " + level
							+ "\n电池的最大值:" + scale
							+ "\n小图标:" + icon_small
							+ "\n充电方式:" + plugged
							+ "\n充电方式: " + acString
							+ "\n电池的电压:" + voltage
							+ "\n电池的温度:" + (float) temperature * 0.1
							+ "\n电池的类型:" + technology);
				}
			}
		};
		@Override
		protected void onPause() {
			super.onPause();
			unregisterReceiver(mBroadcastReceiver);
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_battery"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="获取电池的信息" />
		   <TextView
			android:id="@+id/tv_battery"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			/>
	</LinearLayout>
Android中的广播的使用 
//飞行模式的切换 
	public class MainActivity extends Activity {
		private Button btnStartFly;
		private Button btnStopFly;
		private ContentResolver cr;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			cr = getContentResolver();
			findView();
			setListener();
		}
		private void findView() {
			btnStartFly = (Button) findViewById(R.id.btn_startflying);
			btnStopFly = (Button) findViewById(R.id.btn_stopflying);
		}
		private void setListener() {
			btnStartFly.setOnClickListener(listener);
			btnStopFly.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@SuppressWarnings("deprecation")
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startflying:
					if (Settings.System.getString(cr,
							Settings.System.AIRPLANE_MODE_ON).equals("0")) {
						Log.e("AIRPLANE_MODE_ON", "0");
						Settings.System.putString(cr,
								Settings.System.AIRPLANE_MODE_ON, "1");
						Intent intent = new Intent(
								Intent.ACTION_AIRPLANE_MODE_CHANGED).
								putExtra("state", true);;
						sendBroadcast(intent);
						Toast.makeText(MainActivity.this,
								"已开启飞行模式",
								Toast.LENGTH_SHORT).show();
					}
					break;
				case R.id.btn_stopflying:
					if (Settings.System.getString(cr,
							Settings.System.AIRPLANE_MODE_ON).equals("1")) {
						Log.e("AIRPLANE_MODE_ON", "1");
						Settings.System.putString(cr,
								Settings.System.AIRPLANE_MODE_ON, "0");
						Intent intent = new Intent(
								Intent.ACTION_AIRPLANE_MODE_CHANGED).
								putExtra("state", false);;
						sendBroadcast(intent);
						Toast.makeText(MainActivity.this, "已关闭飞行模式",
								Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startflying"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开启飞行模式" />
		<Button
			android:id="@+id/btn_stopflying"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="关闭飞行模式" />
	</LinearLayout>
//创建桌面快捷方式 
	public class MainActivity extends Activity {
		private static final String CREATE_SHORTCUT_ACTION = "com.android.launcher.action.INSTALL_SHORTCUT";
		private static final String DROP_SHORTCUT_ACTION = "com.android.launcher.action.UNINSTALL_SHORTCUT";
		private Button btnDel;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			addShortcut(MainActivity.this);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			btnDel = (Button) findViewById(R.id.btn_del);
		}
		private void setListener() {
			btnDel.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_del:
					delShortcut(MainActivity.this);
					Toast.makeText(MainActivity.this, "删除成功", Toast.LENGTH_SHORT)
							.show();
				}
			}
		};
		public void addShortcut(Context cx) {
			Intent shortcut = new Intent(CREATE_SHORTCUT_ACTION);
			Intent shortcutIntent = cx.getPackageManager()
					.getLaunchIntentForPackage(cx.getPackageName());
			shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
			String title = null;
			try {
				final PackageManager pm = cx.getPackageManager();
				title = pm.getApplicationLabel(
						pm.getApplicationInfo(cx.getPackageName(),
								PackageManager.GET_META_DATA)).toString();
			} catch (Exception e) {
			}
			shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
			shortcut.putExtra("duplicate", false);
			Parcelable iconResource = Intent.ShortcutIconResource.fromContext(cx,
					R.drawable.ic_launcher);
			shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);

			cx.sendBroadcast(shortcut);
		}
		public void delShortcut(Context cx) {
			Intent shortcut = new Intent(DROP_SHORTCUT_ACTION);
			String title = null;
			try {
				final PackageManager pm = cx.getPackageManager();
				title = pm.getApplicationLabel(
						pm.getApplicationInfo(cx.getPackageName(),
								PackageManager.GET_META_DATA)).toString();
			} catch (Exception e) {
			}
			shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
			Intent shortcutIntent = cx.getPackageManager()
					.getLaunchIntentForPackage(cx.getPackageName());
			shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
			cx.sendBroadcast(shortcut);
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_del"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="删除桌面快捷方式" />
	</LinearLayout>
//程序开机自动启动 
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startafterboot"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开机启动" />
		<Button
			android:id="@+id/btn_notstartafterboot"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开机不启动" />
	</LinearLayout>
//拍照物理键的功能定制 
	public class BootCompletedReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
				Intent newIntent = new Intent(arg0, MainActivity.class);
				newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
				arg0.startActivity(newIntent);
			}
		}
	}
	public class MainActivity extends Activity {
		private Button btnStartAfterBoot;
		private Button btnNotStartAfterBoot;
		private BootCompletedReceiver receiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			receiver=new BootCompletedReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnNotStartAfterBoot = (Button) findViewById(R.id.btn_notstartafterboot);
			btnStartAfterBoot=(Button)findViewById(R.id.btn_startafterboot);
		}
		private void setListener() {
			btnStartAfterBoot.setOnClickListener(listener);
			btnNotStartAfterBoot.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startafterboot:
					registerReceiver(receiver, new IntentFilter("android.intent.action.BOOT_COMPLETED"));
					Toast.makeText(MainActivity.this, "开机自启动已完成", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_notstartafterboot:
					if(receiver!=null)
					{
						unregisterReceiver(receiver);
						Toast.makeText(MainActivity.this, "取消开机自启动已完成", Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startafterboot"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开机启动" />
		<Button
			android:id="@+id/btn_notstartafterboot"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开机不启动" />
	</LinearLayout>
//锁屏广播接收器 
	public class MainActivity extends Activity {
		private Button btnStartTake;
		private Button btnCancelTake;
		private TakePhotoReceiver receiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			receiver=new TakePhotoReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnCancelTake = (Button) findViewById(R.id.btn_notstarttake);
			btnStartTake=(Button)findViewById(R.id.btn_starttake);
		}
		private void setListener() {
			btnStartTake.setOnClickListener(listener);
			btnCancelTake.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_starttake:
					registerReceiver(receiver, new IntentFilter(Intent.ACTION_CAMERA_BUTTON));
					Toast.makeText(MainActivity.this, "拍照广播启动已完成", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_notstarttake:
					if(receiver!=null)
					{
						unregisterReceiver(receiver);
						Toast.makeText(MainActivity.this, "取消拍照广播已完成", Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	public class TakePhotoReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_CAMERA_BUTTON)) {
				Toast.makeText(arg0, "检测到到拍照广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_starttake"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动拍照广播" />
		<Button
			android:id="@+id/btn_notstarttake"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消启动拍照广播" />
	</LinearLayout>
//系统设置信息改变的广播 
	public class LockScreenReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_SCREEN_ON)) {
				Toast.makeText(arg0, "检测到解锁广播", Toast.LENGTH_SHORT).show();
			}else if (arg1.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
				Toast.makeText(arg0, "检测到锁屏广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	public class MainActivity extends Activity {
		private Button btnLockScreen;
		private Button btnCancelLockScreen;
		private Button btnOpenScreen;
		private Button btnCancelOpenScreen;
		private LockScreenReceiver lockReceiver;
		private LockScreenReceiver openReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			lockReceiver=new LockScreenReceiver();
			openReceiver=new LockScreenReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnCancelLockScreen = (Button) findViewById(R.id.btn_cancellockscreen);
			btnCancelOpenScreen=(Button)findViewById(R.id.btn_cancelopenscreen);
			btnOpenScreen=(Button)findViewById(R.id.btn_startopenscreen);
			btnLockScreen=(Button)findViewById(R.id.btn_startlockscreen);
		}
		private void setListener() {
			btnCancelLockScreen.setOnClickListener(listener);
			btnLockScreen.setOnClickListener(listener);
			btnCancelOpenScreen.setOnClickListener(listener);
			btnOpenScreen.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startlockscreen:
					registerReceiver(lockReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
					Toast.makeText(MainActivity.this, "锁屏广播启动已完成", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancellockscreen:
					if(lockReceiver!=null)
					{
						unregisterReceiver(lockReceiver);
						Toast.makeText(MainActivity.this, "取消锁屏广播已完成", Toast.LENGTH_SHORT).show();
					}
					break;
				case R.id.btn_startopenscreen:
					registerReceiver(openReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
					Toast.makeText(MainActivity.this, "解锁广播启动已完成", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelopenscreen:
					if(openReceiver!=null)
					{
						unregisterReceiver(openReceiver);
						Toast.makeText(MainActivity.this, "取消解锁广播已完成", Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startlockscreen"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动锁屏广播" />
		<Button
			android:id="@+id/btn_startopenscreen"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动解锁广播" />
		<Button
			android:id="@+id/btn_cancellockscreen"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消锁屏广播" />
		 <Button
			android:id="@+id/btn_cancelopenscreen"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消解锁广播" />
	</LinearLayout>
//系统内存不足提醒 
	public class MainActivity extends Activity {
		private Button btnSetChange;
		private Button btnCancelSetChange;
		private SetChangeReceiver SetingReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			SetingReceiver=new SetChangeReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnCancelSetChange = (Button) findViewById(R.id.btn_cancelsetchange);
			btnSetChange=(Button)findViewById(R.id.btn_startsetchange);
		}
		private void setListener() {
			btnCancelSetChange.setOnClickListener(listener);
			btnSetChange.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startsetchange:
					registerReceiver(SetingReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
					Toast.makeText(MainActivity.this, "设置改变广播启动已完成", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelsetchange:
					if(SetingReceiver!=null)
					{
						unregisterReceiver(SetingReceiver);
						Toast.makeText(MainActivity.this, "取消设置改变广播已完成", Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	public class SetChangeReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
				Toast.makeText(arg0, "检测到设置改变广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startsetchange"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动设置改变广播" />
		<Button
			android:id="@+id/btn_cancelsetchange"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消设置改变的广播" />
	</LinearLayout>
//接受耳机插入广播 
	public class MainActivity extends Activity {
		private Button btnMemoryLess;
		private Button btnCancelMemoryLess;
		private MemoryLessReceiver memoryLessReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			memoryLessReceiver=new MemoryLessReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnMemoryLess = (Button) findViewById(R.id.btn_cancelmemoryless);
			btnCancelMemoryLess=(Button)findViewById(R.id.btn_startmemoryless);
		}
		private void setListener() {
			btnCancelMemoryLess.setOnClickListener(listener);
			btnMemoryLess.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startmemoryless:
					registerReceiver(memoryLessReceiver, new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW));
					Toast.makeText(MainActivity.this, "设置内存不足广播启动已完成", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelmemoryless:
					if(memoryLessReceiver!=null)
					{
						unregisterReceiver(memoryLessReceiver);
						Toast.makeText(MainActivity.this, "取消内存不足广播已完成", Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	public class MemoryLessReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_DEVICE_STORAGE_LOW)) {
				Toast.makeText(arg0, "检测到内存不足广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startmemoryless"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动内存不足广播" />
		<Button
			android:id="@+id/btn_cancelmemoryless"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消内存不足广播" />
	</LinearLayout>
//手机区域设置更改监听器 
	public class EarphoneInsertReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_HEADSET_PLUG)) {
				Toast.makeText(arg0, "检测到耳机插入广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	public class MainActivity extends Activity {
		private Button btnEarphoneInsert;
		private Button btnCancelEarphoneInsert;
		private EarphoneInsertReceiver earphoneInsertReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			earphoneInsertReceiver = new EarphoneInsertReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnEarphoneInsert = (Button) findViewById(R.id.btn_startearphoneinsert);
			btnCancelEarphoneInsert = (Button) findViewById(R.id.btn_cancelearphoneinsert);
		}
		private void setListener() {
			btnEarphoneInsert.setOnClickListener(listener);
			btnCancelEarphoneInsert.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startearphoneinsert:
					registerReceiver(earphoneInsertReceiver, new IntentFilter(
							Intent.ACTION_HEADSET_PLUG));
					Toast.makeText(MainActivity.this, "设置耳机插入广播启动已完成",
							Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelearphoneinsert:
					if (earphoneInsertReceiver != null) {
						unregisterReceiver(earphoneInsertReceiver);
						Toast.makeText(MainActivity.this, "取消耳机插入广播已完成",
								Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startearphoneinsert"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动耳机插入广播" />
		<Button
			android:id="@+id/btn_cancelearphoneinsert"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消耳机插入广播" />
	</LinearLayout>
//SDCard插入的广播 
	public class AreaChangeReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_LOCALE_CHANGED)) {
				Toast.makeText(arg0, "检测到当前区域设置已更改广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	public class MainActivity extends Activity {
		private Button btnAreaChange;
		private Button btnCancelAreaChange;
		private AreaChangeReceiver areaChangeReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			areaChangeReceiver = new AreaChangeReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnAreaChange = (Button) findViewById(R.id.btn_startedistancechange);
			btnCancelAreaChange = (Button) findViewById(R.id.btn_canceldistancechange);
		}
		private void setListener() {
			btnAreaChange.setOnClickListener(listener);
			btnCancelAreaChange.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startedistancechange:
					registerReceiver(areaChangeReceiver, new IntentFilter(
							Intent.ACTION_LOCALE_CHANGED));
					Toast.makeText(MainActivity.this, "设置当前区域设置已更改广播启动已完成",
							Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_canceldistancechange:
					if (areaChangeReceiver != null) {
						unregisterReceiver(areaChangeReceiver);
						Toast.makeText(MainActivity.this, "取消当前区域设置已更改广播已完成",
								Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startedistancechange"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动当前区域设置已更改广播" />
		<Button
			android:id="@+id/btn_canceldistancechange"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消当前区域设置已更改广播" />
	</LinearLayout>
//SDCard移除的广播 
	public class MainActivity extends Activity {
		private Button btnSdCardInsert;
		private Button btnCancelSdCardInsert;
		private SdcardInsertReceiver sdcardInsertReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			sdcardInsertReceiver=new SdcardInsertReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnSdCardInsert = (Button) findViewById(R.id.btn_startedsdcardinsert);
			btnCancelSdCardInsert=(Button)findViewById(R.id.btn_cancelsdcardinsert);
		}
		private void setListener() {
			btnSdCardInsert.setOnClickListener(listener);
			btnCancelSdCardInsert.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startedsdcardinsert:
					registerReceiver(sdcardInsertReceiver, new IntentFilter(Intent.ACTION_MEDIA_MOUNTED));
					Toast.makeText(MainActivity.this, "设置SD卡插入广播启动已完成", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelsdcardinsert:
					if(sdcardInsertReceiver!=null)
					{
						unregisterReceiver(sdcardInsertReceiver);
						Toast.makeText(MainActivity.this, "取消SD卡插入广播已完成", Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	public class SdcardInsertReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_MEDIA_MOUNTED)) {
				Toast.makeText(arg0, "检测到SD卡插入广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startedsdcardinsert"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动sdcard的插入广播" />
		<Button
			android:id="@+id/btn_cancelsdcardinsert"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消sdcard的插入广播" />
	</LinearLayout>
//APK安装完成的广播 
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startedinstallapk"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动安装完成APK的广播" />
		<Button
			android:id="@+id/btn_cancelinstallapk"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消安装完成APK的拔出广播" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button btnInstallApk;
		private Button btnCancelInstallApk;
		private InstallApkReceiver installApkReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			installApkReceiver=new InstallApkReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnInstallApk = (Button) findViewById(R.id.btn_startedinstallapk);
			btnCancelInstallApk=(Button)findViewById(R.id.btn_cancelinstallapk);
		}
		private void setListener() {
			btnInstallApk.setOnClickListener(listener);
			btnCancelInstallApk.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startedinstallapk:
					registerReceiver(installApkReceiver, new IntentFilter(Intent.ACTION_PACKAGE_ADDED));
					Toast.makeText(MainActivity.this, "设置安装完成APK广播启动已完成", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelinstallapk:
					if(installApkReceiver!=null)
					{
						unregisterReceiver(installApkReceiver);
						Toast.makeText(MainActivity.this, "取消安装完成APK广播已完成", Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	public class InstallApkReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) {
				Toast.makeText(arg0, "检测到安装完成APK广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
//APK卸载完成的广播 
	public class MainActivity extends Activity {
		private Button btnUnstallApk;
		private Button btnCancelUnstallApk;
		private UnstallApkReceiver unstallApkReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			unstallApkReceiver=new UnstallApkReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnUnstallApk = (Button) findViewById(R.id.btn_startedunstallapk);
			btnCancelUnstallApk=(Button)findViewById(R.id.btn_cancelunstallapk);
		}
		private void setListener() {
			btnUnstallApk.setOnClickListener(listener);
			btnCancelUnstallApk.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startedunstallapk:
					registerReceiver(unstallApkReceiver, new IntentFilter(Intent.ACTION_PACKAGE_REMOVED));
					Toast.makeText(MainActivity.this, "设置卸载APK广播启动已完成", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelunstallapk:
					if(unstallApkReceiver!=null)
					{
						unregisterReceiver(unstallApkReceiver);
						Toast.makeText(MainActivity.this, "取消卸载APK广播已完成", Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	public class UnstallApkReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)) {
				Toast.makeText(arg0, "检测到卸载APK广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startedunstallapk"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动卸载APK的广播" />
		<Button
			android:id="@+id/btn_cancelunstallapk"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消安卸载APK的拔出广播" />
	</LinearLayout>
//外部电源接入的广播 
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startedplugin"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动插上外部电源的广播" />
		<Button
			android:id="@+id/btn_cancelplugin"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消插上外部电源的拔出广播" />
	</LinearLayout>
	public class PlugInReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_POWER_CONNECTED)) {
				Toast.makeText(arg0, "检测到插上外部电源广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	public class MainActivity extends Activity {
		private Button btnPlugIn;
		private Button btnCancelPlugIn;
		private PlugInReceiver plugInReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			plugInReceiver = new PlugInReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnPlugIn = (Button) findViewById(R.id.btn_startedplugin);
			btnCancelPlugIn = (Button) findViewById(R.id.btn_cancelplugin);
		}
		private void setListener() {
			btnPlugIn.setOnClickListener(listener);
			btnCancelPlugIn.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startedplugin:
					registerReceiver(plugInReceiver, new IntentFilter(
							Intent.ACTION_POWER_CONNECTED));
					Toast.makeText(MainActivity.this, "设置插上外部电源广播启动已完成",
							Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelplugin:
					if (plugInReceiver != null) {
						unregisterReceiver(plugInReceiver);
						Toast.makeText(MainActivity.this, "取消插上外部电源广播已完成",
								Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
//重启系统的广播 
	public class MainActivity extends Activity {
		private Button btnRestartPhone;
		private Button btnCancelRestartPhone;
		private RestartPhoneReceiver restartPhoneReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			restartPhoneReceiver=new RestartPhoneReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnRestartPhone = (Button) findViewById(R.id.btn_startrestartphone);
			btnCancelRestartPhone=(Button)findViewById(R.id.btn_cancelrestartphone);
		}
		private void setListener() {
			btnRestartPhone.setOnClickListener(listener);
			btnCancelRestartPhone.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startrestartphone:
					registerReceiver(restartPhoneReceiver, new IntentFilter(Intent.ACTION_REBOOT));
					Toast.makeText(MainActivity.this, "设置重启设备广播启动已完成", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelrestartphone:
					if(restartPhoneReceiver!=null)
					{
						unregisterReceiver(restartPhoneReceiver);
						Toast.makeText(MainActivity.this, "取消重启设备广播已完成", Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	public class RestartPhoneReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_REBOOT)) {
				Toast.makeText(arg0, "检测到重启设备广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startrestartphone"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动重启设备的广播" />
		<Button
			android:id="@+id/btn_cancelrestartphone"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消重启设备的拔出广播" />
	</LinearLayout>
//断开电源的广播 
	public class BreakPowerReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_POWER_DISCONNECTED)) {
				Toast.makeText(arg0, "检测到已断开外部电源连接广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	public class MainActivity extends Activity {
		private Button btnBreakPower;
		private Button btnCancelBreakPower;
		private BreakPowerReceiver breakPowerReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			breakPowerReceiver=new BreakPowerReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnBreakPower = (Button) findViewById(R.id.btn_startbreakpower);
			btnCancelBreakPower=(Button)findViewById(R.id.btn_cancelbreakpower);
		}
		private void setListener() {
			btnBreakPower.setOnClickListener(listener);
			btnCancelBreakPower.setOnClickListener(listener);
		}
		OnClickListener listener=new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startbreakpower:
					registerReceiver(breakPowerReceiver, new IntentFilter(Intent.ACTION_POWER_DISCONNECTED));
					Toast.makeText(MainActivity.this, "设置已断开外部电源连接广播启动已完成", Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelbreakpower:
					if(breakPowerReceiver!=null)
					{
						unregisterReceiver(breakPowerReceiver);
						Toast.makeText(MainActivity.this, "取消已断开外部电源连接广播已完成", Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startbreakpower"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动断开外部电源连接的广播" />
		<Button
			android:id="@+id/btn_cancelbreakpower"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消断开外部电源连接的广播" />
	</LinearLayout>
//墙纸改变的广播 
	public class ChangeWallerReceiver extends BroadcastReceiver {
		@SuppressWarnings("deprecation")
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_WALLPAPER_CHANGED)) {
				Toast.makeText(arg0, "检测到更换壁纸的广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	public class MainActivity extends Activity {
		private Button btnChangeWaller;
		private Button btnCancelChangeWaller;
		private ChangeWallerReceiver changeWallerReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			changeWallerReceiver = new ChangeWallerReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnChangeWaller = (Button) findViewById(R.id.btn_startchangewaller);
			btnCancelChangeWaller = (Button) findViewById(R.id.btn_cancelchangewaller);
		}
		private void setListener() {
			btnChangeWaller.setOnClickListener(listener);
			btnCancelChangeWaller.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startchangewaller:
					registerReceiver(changeWallerReceiver, new IntentFilter(
							Intent.ACTION_WALLPAPER_CHANGED));
					Toast.makeText(MainActivity.this, "设置更换壁纸广播启动已完成",
							Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelchangewaller:
					if (changeWallerReceiver != null) {
						unregisterReceiver(changeWallerReceiver);
						Toast.makeText(MainActivity.this, "取消更换壁纸广播已完成",
								Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startchangewaller"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动更换壁纸的广播" />
		<Button
			android:id="@+id/btn_cancelchangewaller"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消更换壁纸的广播" />
	</LinearLayout>
//电话黑名单 
	<LinearLayout 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:orientation="vertical" >
		<EditText 
			android:id="@+id/et_blackphone"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:hint="请输入要拦截的号码"
			/>
		<Button
			android:id="@+id/btn_startholdup"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动拦截号码的广播" />
	   
		<Button
			android:id="@+id/btn_cancelholdup"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消拦截号码的广播" />
	</LinearLayout>
	public class HoldUpReceiver extends BroadcastReceiver {
		private String holdUpPhone;
		public HoldUpReceiver(String string) {
			holdUpPhone = string;
		}
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(MainActivity.PHONE_STATE)) {
				Toast.makeText(arg0, "检测到来电的广播", Toast.LENGTH_SHORT).show();
				String phoneNumber = arg1
						.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
				TelephonyManager telephony = (TelephonyManager) arg0
						.getSystemService(Context.TELEPHONY_SERVICE);
				int state = telephony.getCallState();
				switch (state) {
				case TelephonyManager.CALL_STATE_RINGING:
					if (holdUpPhone.equals(phoneNumber)) {
						holdupphone(telephony);
					}
					break;
				case TelephonyManager.CALL_STATE_IDLE:
					Toast.makeText(arg0,
							"idle: " + arg1.getStringExtra("incoming_number"),
							Toast.LENGTH_LONG).show();
					break;
				case TelephonyManager.CALL_STATE_OFFHOOK:
					Toast.makeText(arg0,
							"OffHook: " + arg1.getStringExtra("incoming_number"),
							Toast.LENGTH_LONG).show();
					break;
				}
			}
		}
		public void holdupphone(TelephonyManager teleManager) {
			Class c;
			try {
				c = Class.forName(teleManager.getClass().getName());
				Method m = c.getDeclaredMethod("getITelephony");
				m.setAccessible(true);
				ITelephony iTelephony = (ITelephony) m.invoke(teleManager);
				iTelephony.endCall();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			} catch (SecurityException e) {
				e.printStackTrace();
			} catch (NoSuchMethodException e) {
				e.printStackTrace();
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				e.printStackTrace();
			} catch (RemoteException e) {
				e.printStackTrace();
			}
		}
	}
	public class MainActivity extends Activity {
		private Button btnHoldUp;
		private Button btnCancelHoldUp;
		private EditText etHoldUpPhone;
		public final static String PHONE_STATE = TelephonyManager.ACTION_PHONE_STATE_CHANGED;
		private HoldUpReceiver holdUpReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			btnHoldUp = (Button) findViewById(R.id.btn_startholdup);
			btnCancelHoldUp = (Button) findViewById(R.id.btn_cancelholdup);
			etHoldUpPhone = (EditText) findViewById(R.id.et_blackphone);
		}
		private void setListener() {
			btnHoldUp.setOnClickListener(listener);
			btnCancelHoldUp.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startholdup:
					holdUpReceiver = new HoldUpReceiver(etHoldUpPhone.getText()
							.toString());
					registerReceiver(holdUpReceiver, new IntentFilter(PHONE_STATE));
					Toast.makeText(MainActivity.this, "设置拦截号码广播启动已完成",
							Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelholdup:
					if (holdUpReceiver != null) {
						unregisterReceiver(holdUpReceiver);
						Toast.makeText(MainActivity.this, "取消拦截号码广播已完成",
								Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
//短信接收的广播 
	public class MainActivity extends Activity {
		private Button btnReceiverMsg;
		private Button btnCancelReceiverMsg;
		private ReceiverMsgReceiver receiverMsgReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			receiverMsgReceiver = new ReceiverMsgReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnReceiverMsg = (Button) findViewById(R.id.btn_startreceivemessage);
			btnCancelReceiverMsg = (Button) findViewById(R.id.btn_cancelreceivemessage);
		}
		private void setListener() {
			btnReceiverMsg.setOnClickListener(listener);
			btnCancelReceiverMsg.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startreceivemessage:
					registerReceiver(receiverMsgReceiver, new IntentFilter(
							"android.provider.Telephony.SMS_RECEIVED"));
					Toast.makeText(MainActivity.this, "设置短信接收广播启动已完成",
							Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelreceivemessage:
					if (receiverMsgReceiver != null) {
						unregisterReceiver(receiverMsgReceiver);
						Toast.makeText(MainActivity.this, "取消短信接收广播已完成",
								Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
	public class ReceiverMsgReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
				Toast.makeText(arg0, "检测到短信到达的广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startreceivemessage"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动短信接收的广播" />
		<Button
			android:id="@+id/btn_cancelreceivemessage"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消短信接收的广播" />
	</LinearLayout>
//短信发送的广播 
	public class MainActivity extends Activity {
		public static String SMS_SEND_ACTIOIN = "SMS_SEND_ACTIOIN";
		public static String SMS_DELIVERED_ACTION = "SMS_DELIVERED_ACTION";
		private SendMsgReceiver sendReceiver, deliverReceiver;
		private EditText etSendPhone;
		private EditText etSendBody;
		private Button btnSendMsg;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			etSendPhone = (EditText) findViewById(R.id.et_sendphone);
			etSendBody = (EditText) findViewById(R.id.et_sendbody);
			btnSendMsg = (Button) findViewById(R.id.btn_sendmessage);
		}
		private void setListener() {
			btnSendMsg.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_sendmessage:
					String strDestAddress = etSendPhone.getText().toString();
					String strMessage = etSendBody.getText().toString();
					SmsManager smsManager = SmsManager.getDefault();
					try {
						Intent itSend = new Intent(SMS_SEND_ACTIOIN);
						Intent itDeliver = new Intent(SMS_DELIVERED_ACTION);
						PendingIntent mSendPI = PendingIntent.getBroadcast(
								getApplicationContext(), 0, itSend, 0);
						PendingIntent mDeliverPI = PendingIntent.getBroadcast(
								getApplicationContext(), 0, itDeliver, 0);
						smsManager.sendTextMessage(strDestAddress, null,
								strMessage, mSendPI, mDeliverPI);
					} catch (Exception e) {
						e.printStackTrace();
					}
					break;
				}
			}
		};
		@Override
		protected void onResume() {
			IntentFilter mFilter01;
			mFilter01 = new IntentFilter(SMS_SEND_ACTIOIN);
			sendReceiver = new SendMsgReceiver();
			registerReceiver(sendReceiver, mFilter01);
			mFilter01 = new IntentFilter(SMS_DELIVERED_ACTION);
			deliverReceiver = new SendMsgReceiver();
			registerReceiver(deliverReceiver, mFilter01);
			super.onResume();
		}
		@Override
		protected void onPause() {
			super.onPause();
			unregisterReceiver(sendReceiver);
			unregisterReceiver(deliverReceiver);
		}
	}
	public class SendMsgReceiver extends BroadcastReceiver {
		private Context context;
		@Override
		public void onReceive(Context context, Intent intent) {
			this.context = context;
			if (intent.getAction().equals(MainActivity.SMS_SEND_ACTIOIN)) {
				try {
					switch (getResultCode()) {
					case MainActivity.RESULT_OK:
						mMakeTextToast("短信发送成功");
						break;
					case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
						mMakeTextToast("发送短信失败");
						break;
					}
				} catch (Exception e) {
					e.getStackTrace();
				}
			} else if (intent.getAction().equals(MainActivity.SMS_DELIVERED_ACTION)) {
				try {
					switch (getResultCode()) {
					case MainActivity.RESULT_OK:
						mMakeTextToast("短信到达");
						break;
					case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
						mMakeTextToast("短信未送达");
						break;
					}
				} catch (Exception e) {
					e.getStackTrace();
				}
			}
		}
		private void mMakeTextToast(String string) {
			Toast.makeText(context, string, Toast.LENGTH_SHORT).show();
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<EditText
			android:id="@+id/et_sendphone"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="10086"
			android:hint="发送的手机号" />
		<EditText
			android:id="@+id/et_sendbody"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="hello world!"
			android:hint="发送的内容" />
	   
		<Button
			android:id="@+id/btn_sendmessage"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="发送" />
	</LinearLayout>
//电池电量低的广播 
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startpowerlow"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="启动电池电量低的广播" />
		<Button
			android:id="@+id/btn_cancelpowerlow"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="取消电池电量低的广播" />
	</LinearLayout>
	public class PowerLowReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context arg0, Intent arg1) {
			if (arg1.getAction().equals(Intent.ACTION_BATTERY_LOW)) {
				Toast.makeText(arg0, "检测到电池电量低的广播", Toast.LENGTH_SHORT).show();
			}
		}
	}
	public class MainActivity extends Activity {
		private Button btnPowerLow;
		private Button btnCancelPowerLow;
		private PowerLowReceiver powerLowReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			powerLowReceiver = new PowerLowReceiver();
			findView();
			setListener();
		}
		private void findView() {
			btnPowerLow = (Button) findViewById(R.id.btn_startpowerlow);
			btnCancelPowerLow = (Button) findViewById(R.id.btn_cancelpowerlow);
		}
		private void setListener() {
			btnPowerLow.setOnClickListener(listener);
			btnCancelPowerLow.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_startpowerlow:
					registerReceiver(powerLowReceiver, new IntentFilter(
							Intent.ACTION_BATTERY_LOW));
					Toast.makeText(MainActivity.this, "设置电池电量低广播启动已完成",
							Toast.LENGTH_SHORT).show();
					break;
				case R.id.btn_cancelpowerlow:
					if (powerLowReceiver != null) {
						unregisterReceiver(powerLowReceiver);
						Toast.makeText(MainActivity.this, "取消电池电量低广播已完成",
								Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
	}
//音乐播放器 
	<LinearLayout 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:orientation="vertical" >
		<SeekBar
			android:id="@+id/sb_musicprogress"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			 />
		<Button
			android:id="@+id/bt_start"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开始" />
		<Button
			android:id="@+id/btn_stop"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="停止" />
	</LinearLayout>
	public class MusicService extends Service {
		private MediaPlayer mPlayer;
		private Intent broadCastCurrentIntent;
		private Intent broadCastTotalIntent;
		@Override
		public IBinder onBind(Intent arg0) {
			return null;
		}
		@Override
		public void onCreate() {
			Toast.makeText(this, "MusicSevice onCreate()", Toast.LENGTH_SHORT)
					.show();
			mPlayer = MediaPlayer.create(getApplicationContext(), R.raw.music);
			broadCastCurrentIntent = new Intent(
					MainActivity.ACTION_START_UPDATE_PROGRESS);
			broadCastTotalIntent = new Intent(
					MainActivity.ACTION_START_TOTAL_PROGRESS);
			super.onCreate();
		}
		@Override
		public int onStartCommand(final Intent intent, int flags, int startId) {
			Toast.makeText(this, "MusicSevice onStart()", Toast.LENGTH_SHORT)
					.show();
			if (intent.getBooleanExtra("musicstate", true)) {
				mPlayer.start();
				broadCastTotalIntent.putExtra("TotalPosition",
						mPlayer.getDuration());
				sendBroadcast(broadCastTotalIntent);
				new Thread(new Runnable() {
					@Override
					public void run() {
						while (mPlayer.getCurrentPosition() <= mPlayer
								.getDuration()) {
							broadCastCurrentIntent.putExtra("CurrentPosition",
									mPlayer.getCurrentPosition());
							sendBroadcast(broadCastCurrentIntent);
							try {
								Thread.sleep(500);
							} catch (InterruptedException e) {
								e.printStackTrace();
							}
						}

					}
				}).start();
			} else {
				mPlayer.stop();
			}
			return super.onStartCommand(intent, flags, startId);
		}
	}
	public class MainActivity extends Activity {
		public static String ACTION_START_UPDATE_PROGRESS = "update_progress";
		public static String ACTION_START_TOTAL_PROGRESS = "total_progress";
		private SeekBar sbMusicProgress;
		private Button btnStart;
		private Button btnStop;
		private Intent serviceIntent;
		private MusicBordcastReceiver musicBordcastReceiver;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
			serviceIntent = new Intent(this, MusicService.class);
			musicBordcastReceiver = new MusicBordcastReceiver();
		}
		private void findView() {
			sbMusicProgress = (SeekBar) findViewById(R.id.sb_musicprogress);
			btnStop = (Button) findViewById(R.id.btn_stop);
			btnStart = (Button) findViewById(R.id.bt_start);
		}
		private void setListener() {
			btnStart.setOnClickListener(listener);
			btnStop.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.bt_start:
					serviceIntent.putExtra("musicstate", true);
					startService(serviceIntent);
					break;
				case R.id.btn_stop:
					serviceIntent.putExtra("musicstate", false);
					startService(serviceIntent);
					break;
				}
			}
		};
		private class MusicBordcastReceiver extends BroadcastReceiver {
			@Override
			public void onReceive(Context context, Intent intent) {
				if (intent.getAction().equals(ACTION_START_UPDATE_PROGRESS)) {
					sbMusicProgress.setProgress(intent.getIntExtra(
							"CurrentPosition", 0));
				}
				if (intent.getAction().equals(ACTION_START_TOTAL_PROGRESS)) {
					sbMusicProgress.setMax(intent.getIntExtra("TotalPosition", 0));
				}
			}

		}
		@Override
		protected void onResume() {
			if (musicBordcastReceiver == null) {
				musicBordcastReceiver = new MusicBordcastReceiver();
			}
			IntentFilter intentFilter = new IntentFilter();
			intentFilter.addAction(ACTION_START_UPDATE_PROGRESS);
			intentFilter.addAction(ACTION_START_TOTAL_PROGRESS);
			registerReceiver(musicBordcastReceiver, intentFilter);
			super.onResume();
		}
		@Override
		protected void onStop() {
			unregisterReceiver(musicBordcastReceiver);
			super.onStop();
		}
	}
Android的网络编程
网络请求 
//在线天气查询 
	public class MainActivity extends Activity {
		private TextView mTvShow;
		private EditText mEtInPut; 
		private Button mBtn; 
		private ProgressBar mProgressBar; 
		private Handler mHandler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				mProgressBar.setVisibility(View.GONE);
				mTvShow.setText(mReturnConnection);
				super.handleMessage(msg);
			}

		};
		private String mReturnConnection;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			setTitle("POST天气查询");
			findView();
			setListener();
		}
		private void findView() {
			mBtn = (Button) findViewById(R.id.btn);
			mEtInPut = (EditText) findViewById(R.id.et);
			mTvShow = (TextView) findViewById(R.id.tv_show);
			mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
		}
		private void setListener() {
			mBtn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					mProgressBar.setVisibility(View.VISIBLE);
					new Thread() {
						@Override
						public void run() {
							dopost(mEtInPut.getText().toString());
							mHandler.sendEmptyMessage(0);
							super.run();
						}
					}.start();
				}
			});
		}
		private void dopost(String val) {
			DefaultHttpClient client = new DefaultHttpClient();
			HttpPost httpPost = new HttpPost(
					"http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx/getWeather");
			List<NameValuePair> params = new ArrayList<NameValuePair>();
			params.add(new BasicNameValuePair("theCityCode", val));
			params.add(new BasicNameValuePair("theUserID", ""));
			try {
				UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(params,
						"utf-8");
				httpPost.setEntity(p_entity);
				HttpResponse response = client.execute(httpPost);
				if (response.getStatusLine().getStatusCode() == 200) {
					mReturnConnection = EntityUtils.toString(response.getEntity());
				} else {
					mReturnConnection = "Error Response: "
							+ response.getStatusLine().toString();
				}
			} catch (IllegalStateException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<EditText
			android:id="@+id/et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:layout_alignParentTop="true"
			android:text="石家庄" />
		<Button
			android:id="@+id/btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:layout_below="@+id/et"
			android:text="POST提交,查询天气" />
		<TextView
			android:id="@+id/tv_show"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:layout_below="@+id/btn" />
		<ProgressBar
			android:id="@+id/progressBar"
			style="?android:attr/progressBarStyleLarge"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_centerHorizontal="true"
			android:layout_centerVertical="true"
			android:visibility="gone" />
	</RelativeLayout>
//在线百度搜索 
	public class MainActivity extends Activity {
		private TextView mTvShow; 
		private EditText mEtInPut; 
		private Button mBtn; 
		private ProgressBar mProgressBar; 
		private Handler mHandler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				mProgressBar.setVisibility(View.GONE);
				mTvShow.setText(mReturnConnection);
				super.handleMessage(msg);
			}
		};
		private String mReturnConnection;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			mBtn = (Button) findViewById(R.id.btn);
			mEtInPut = (EditText) findViewById(R.id.et);
			mTvShow = (TextView) findViewById(R.id.tv_show);
			mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
		}
		private void setListener() {
			mBtn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					mProgressBar.setVisibility(View.VISIBLE);
					new Thread() {
						@Override
						public void run() {
							doGet();
							mHandler.sendEmptyMessage(0);
							super.run();
						}
					}.start();
				}
			});
		}
		public void doGet() {
			BufferedReader in = null;
			String URL = "http://www.baidu.com/s?wd="
					+ mEtInPut.getText().toString();
			try {
				HttpClient client = new DefaultHttpClient();
				HttpGet request = new HttpGet();
				request.setURI(new URI(URL));
				HttpResponse response = client.execute(request);
				if (response.getStatusLine().getStatusCode() == 200) {
					mReturnConnection = EntityUtils.toString(response.getEntity());
				} else {
					mReturnConnection = "Error Response: "
							+ response.getStatusLine().toString();
				}
			} catch (Exception e) {
				Log.e("wyl", e.toString());
			} finally {
				if (in != null) {
					try {
						in.close();
					} catch (IOException ioe) {
						Log.e("wyl", ioe.toString());
					}
				}
			}
		}
	}
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<EditText
			android:id="@+id/et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:layout_alignParentTop="true"
			android:text="石家庄" />
		<Button
			android:id="@+id/btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:layout_below="@+id/et"
			android:text="get提交,百度搜索" />
		<TextView
			android:id="@+id/tv_show"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:layout_below="@+id/btn" />
		<ProgressBar
			android:id="@+id/progressBar"
			style="?android:attr/progressBarStyleLarge"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_centerHorizontal="true"
			android:layout_centerVertical="true"
			android:visibility="gone" />
	</RelativeLayout>
//网络图片下载器 
	public class FileUtils {
		private String SDPATH;
		public String getSDPATH() {
			return SDPATH;
		}
		public FileUtils() {
			SDPATH = Environment.getExternalStorageDirectory() + "/";
		}
		public File creatSDFile(String fileName) throws IOException {
			File file = new File(SDPATH + fileName);
			file.createNewFile();
			return file;
		}
		public File creatSDDir(String dirName) {
			File dir = new File(SDPATH + dirName);
			dir.mkdir();
			return dir;
		}
		public boolean isFileExist(String fileName){
			File file = new File(SDPATH + fileName);
			return file.exists();
		}
		public File write2SDFromInput(String path,String fileName,InputStream input){
			File file = null;
			OutputStream output = null;
			try{
				creatSDDir(path);
				file = creatSDFile(path + fileName);
				output = new FileOutputStream(file);
				byte buffer [] = new byte[4 * 1024];
				while((input.read(buffer)) != -1){
					output.write(buffer);
				}
				output.flush();
			}
			catch(Exception e){
				e.printStackTrace();
			}
			finally{
				try{
					output.close();
				}
				catch(Exception e){
					e.printStackTrace();
				}
			}
			return file;
		}
	}
	public class MainActivity extends Activity {
		private Button mBtn; 
		private EditText mEt;
		private Handler mHandler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				if (msg.what == 0) {
					Toast.makeText(MainActivity.this, "下载成功!",
							Toast.LENGTH_SHORT).show();
				} else if (msg.what == 1) {
					Toast.makeText(MainActivity.this, "已有文件!",
							Toast.LENGTH_SHORT).show();
				} else if (msg.what == -1) {
					Toast.makeText(MainActivity.this, "下载失败!",
							Toast.LENGTH_SHORT).show();
				}
				super.handleMessage(msg);
			}

		};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			mBtn = (Button) findViewById(R.id.btn);
			mEt = (EditText)findViewById(R.id.et);
		}
		private void setListener() {
			mBtn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					new Thread() {
						@Override
						public void run() {
							Message msg = new Message();
							HttpDownloader httpDownLoader = new HttpDownloader();
							msg.what = httpDownLoader
									.downfile(
											mEt.getText().toString(),
											"test/", "test1.jpg");
							mHandler.sendMessage(msg);
							super.run();
						}
					}.start();
				}
			});
		}
		public class HttpDownloader {
			private URL url = null;
			FileUtils fileUtils = new FileUtils();
			public int downfile(String urlStr, String path, String fileName) {
				if (fileUtils.isFileExist(path + fileName)) {
					return 1;
				} else {
					try {
						InputStream input = null;
						input = getInputStream(urlStr);
						File resultFile = fileUtils.write2SDFromInput(path,
								fileName, input);
						if (resultFile == null) {
							return -1;
						}
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
				return 0;
			}
			public InputStream getInputStream(String urlStr) throws IOException {
				InputStream is = null;
				try {
					url = new URL(urlStr);
					HttpURLConnection urlConn = (HttpURLConnection) url
							.openConnection();
					is = urlConn.getInputStream();
				} catch (MalformedURLException e) {
					e.printStackTrace();
				}
				return is;
			}
		}
	}
	<LinearLayout
  	xmlns:android="http://schemas.android.com/apk/res/android"
  	android:layout_width="fill_parent"
  	android:layout_height="wrap_content"
  	android:paddingLeft="5dip"
  	android:paddingRight="5dip"
  	android:orientation="vertical">  
		<ProgressBar
			android:id="@+id/update_progress"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			style="?android:attr/progressBarStyleHorizontal"/>
		<TextView 
			android:id="@+id/update_progress_text"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_gravity="right"
			android:textColor="@android:color/white"/>
	</LinearLayout>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<EditText
			android:id="@+id/et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:hint="请输入需要下载的网络图片地址"
			/>
		<Button
			android:id="@+id/btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:text="下载网络图片" />
	</LinearLayout>
//文件上传 
	public class MainActivity extends Activity {
		private String newName = "up.png";
		private String uploadFile = "/sdcard/up.png";
		private String actionUrl = "http://192.168.0.71:8086/HelloWord/myForm";
		private TextView mText1;
		private TextView mText2;
		private Button mButton;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			mText1 = (TextView) findViewById(R.id.myText1);
			mText1.setText(uploadFile);
			mText2 = (TextView) findViewById(R.id.myText2);
			mText2.setText(actionUrl);
			mButton = (Button) findViewById(R.id.myButton);
		}
		private void setListener() {
			mButton.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					new Thread(){
						@Override
						public void run() {
							uploadFile();
							super.run();
						}
					}.start();
				}
			});
		}
		private void uploadFile() {
			String end = "\r\n";
			String twoHyphens = "--";
			String boundary = "*****";
			try {
				URL url = new URL(actionUrl);
				HttpURLConnection con = (HttpURLConnection) url.openConnection();
				con.setDoInput(true);
				con.setDoOutput(true);
				con.setUseCaches(false);
				con.setRequestMethod("POST");
				con.setRequestProperty("Connection", "Keep-Alive");
				con.setRequestProperty("Charset", "UTF-8");
				con.setRequestProperty("Content-Type",
						"multipart/form-data;boundary=" + boundary);
				DataOutputStream ds = new DataOutputStream(con.getOutputStream());
				ds.writeBytes(twoHyphens + boundary + end);
				ds.writeBytes("Content-Disposition: form-data; "
						+ "name=\"file1\";filename=\"" + newName + "\"" + end);
				ds.writeBytes(end);
				FileInputStream fStream = new FileInputStream(uploadFile);
				int bufferSize = 1024;
				byte[] buffer = new byte[bufferSize];
				int length = -1;
				while ((length = fStream.read(buffer)) != -1) {
					ds.write(buffer, 0, length);
				}
				ds.writeBytes(end);
				ds.writeBytes(twoHyphens + boundary + twoHyphens + end);
				fStream.close();
				ds.flush();
				InputStream is = con.getInputStream();
				int ch;
				StringBuffer b = new StringBuffer();
				while ((ch = is.read()) != -1) {
					b.append((char) ch);
				}
				showDialog("上传成功" + b.toString().trim());
				ds.close();
			} catch (Exception e) {
				showDialog("上传失败" + e);
			}
		}
		private void showDialog(String mess) {
			new AlertDialog.Builder(MainActivity.this).setTitle("Message")
					.setMessage(mess)
					.setNegativeButton("确定", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int which) {
						}
					}).show();
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<TextView
			android:id="@+id/myText1"
			android:layout_width="match_parent"
			android:layout_height="wrap_content" />
		<TextView
			android:id="@+id/myText2"
			android:layout_width="match_parent"
			android:layout_height="wrap_content" />
		<Button
			android:id="@+id/myButton"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="上传文件" />
	</LinearLayout>
//异步图片加载 
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    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=".MainActivity" >
		<Button
			android:id="@+id/btn_picTask"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:layout_alignParentTop="true"
			android:text="异步下载图片" />
		<ImageView
			android:id="@+id/image"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:layout_alignParentLeft="true"
			android:layout_below="@+id/btn_picTask"
			android:padding="2dp"
			android:scaleType="centerInside" />
	</RelativeLayout>
	public class AsyncPicTask extends AsyncTask<Object, Integer, Bitmap> {
		private ImageView iv_pic;
		@Override
		protected Bitmap doInBackground(Object... params) {
			Bitmap bitmap = null;
			iv_pic = (ImageView) params[0];
			try {
				URL url = new URL((String) params[1]);
				HttpURLConnection conn = (HttpURLConnection) url.openConnection();
				conn.setDoInput(true);
				conn.connect();
				InputStream inputStream = conn.getInputStream();
				bitmap = BitmapFactory.decodeStream(inputStream);
				inputStream.close();
			} catch (MalformedURLException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return bitmap;
		}
		@Override
		protected void onPostExecute(Bitmap result) {
			if (result != null) {
				iv_pic.setImageBitmap(result);
			}
		}
	}
	public class MainActivity extends Activity {
		private static final String URL = "http://pica.nipic.com/2008-07-01/200871134114809_2.jpg";
		private Button mBtnPicTask;
		private ImageView mIvPic;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			mBtnPicTask = (Button) findViewById(R.id.btn_picTask);
			mIvPic = (ImageView) findViewById(R.id.image);
		}
		private void setListener() {
			mBtnPicTask.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					AsyncPicTask picTask = new AsyncPicTask();
					picTask.execute(mIvPic, URL);
				}
			});
		}
	}
//UDP网络通信 
	public class MainActivity extends Activity {
		private EditText mEtMsg = null;
		private Button mBtnSend = null;
		private TextView mTvInfo = null;
		private String mStrResult = null;
		private Handler mHandler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);
				mTvInfo.setText(mStrResult);
			}
		};
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			mEtMsg=(EditText)findViewById(R.id.msg_et);
			mBtnSend=(Button)findViewById(R.id.send_bt);
			mTvInfo=(TextView)findViewById(R.id.info_tv);
			ExecutorService exec=Executors.newCachedThreadPool();
			UDPServer server=new UDPServer();
			exec.execute(server);
			mBtnSend.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					new Thread(){
						public void run() {
							UDPClient client=new UDPClient(mEtMsg.getText().toString());
							mStrResult = client.send();
							mHandler.sendEmptyMessage(0);
							super.run();
						}
					}.start();
				}
			});
		}
	}
	public class UDPClient {
		private static final int SERVER_PORT = 6000;
		private DatagramSocket mDSocket = null;
		private String mMsg;
		public UDPClient(String msg) {
			super();
			this.mMsg = msg;
		}
		public String send() {
			StringBuilder sb = new StringBuilder();
			InetAddress local = null;
			try {
				local = InetAddress.getByName("localhost");
				sb.append("已找到服务器,连接中...").append("/n");
			} catch (UnknownHostException e) {
				sb.append("未找到服务器.").append("/n");
				e.printStackTrace();
			}
			try {
				mDSocket = new DatagramSocket(); 
				sb.append("正在连接服务器...").append("/n");
			} catch (SocketException e) {
				e.printStackTrace();
				sb.append("服务器连接失败.").append("/n");
			}
			int msg_len = mMsg == null ? 0 : mMsg.length();
			DatagramPacket dPacket = new DatagramPacket(mMsg.getBytes(), msg_len,
					local, SERVER_PORT);
			try {
				mDSocket.send(dPacket);
				sb.append("消息发送成功!").append("/n");
			} catch (IOException e) {
				e.printStackTrace();
				sb.append("消息发送失败.").append("/n");
			}
			mDSocket.close();
			return sb.toString();
		}
	}
	public class UDPServer implements Runnable {
		private static final int PORT = 6000;
		private byte[] msg = new byte[1024];
		private boolean life = true;
		public UDPServer() {
		}
		public boolean isLife() {
			return life;
		}
		public void setLife(boolean life) {
			this.life = life;
		}
		@Override
		public void run() {
			DatagramSocket dSocket = null;
			DatagramPacket dPacket = new DatagramPacket(msg, msg.length);
			try {
				dSocket = new DatagramSocket(PORT);
				while (life) {
					try {
						dSocket.receive(dPacket);
						Log.i("msg sever received", new String(dPacket.getData()));
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			} catch (SocketException e) {
				e.printStackTrace();
			}
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<EditText
			android:id="@+id/msg_et"
			android:layout_width="match_parent"
			android:layout_height="wrap_content" />
		<Button
			android:id="@+id/send_bt"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:text="发送" />
		<TextView
			android:id="@+id/info_tv"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content" />
	</LinearLayout>
//在线音乐播放 
	public class MainActivity extends Activity {
		private Button mBtnPause; 
		private Button mBtnPlayUrl; 
		private Button mBtnStop; 
		private SeekBar mSkbProgress;
		private Player mPlayer; 
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
			mPlayer = new Player(mSkbProgress);
		}
		private void findView() {
			mBtnPlayUrl = (Button) this.findViewById(R.id.btnPlayUrl);
			mBtnPause = (Button) this.findViewById(R.id.btnPause);
			mBtnStop = (Button) this.findViewById(R.id.btnStop);
			mSkbProgress = (SeekBar) this.findViewById(R.id.skbProgress);
		}
		private void setListener() {
			mBtnPlayUrl.setOnClickListener(new ClickEvent());
			mBtnPause.setOnClickListener(new ClickEvent());
			mBtnStop.setOnClickListener(new ClickEvent());
			mSkbProgress.setOnSeekBarChangeListener(new SeekBarChangeEvent());
		}
		class ClickEvent implements OnClickListener {
			@Override
			public void onClick(View arg0) {
				if (arg0 == mBtnPause) {
					mPlayer.pause();
				} else if (arg0 == mBtnPlayUrl) {
					String url = "http://m.zonse.net/music/data/upload/12532622.mp3";
					mPlayer.playUrl(url);
				} else if (arg0 == mBtnStop) {
					mPlayer.stop();
				}
			}
		}
		class SeekBarChangeEvent implements SeekBar.OnSeekBarChangeListener {
			int progress;
			@Override
			public void onProgressChanged(SeekBar seekBar, int progress,
					boolean fromUser) {
				this.progress = progress * mPlayer.mMediaPlayer.getDuration()
						/ seekBar.getMax();
			}
			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {
			}
			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {
				mPlayer.mMediaPlayer.seekTo(progress);
			}
		}
	}
	public class Player implements OnBufferingUpdateListener,
			OnCompletionListener,
			MediaPlayer.OnPreparedListener {
		public MediaPlayer mMediaPlayer;
		private SeekBar mSkbProgress; 
		private Timer mTimer = new Timer();
		public Player(SeekBar skbProgress) {
			this.mSkbProgress = skbProgress;
			try {
				mMediaPlayer = new MediaPlayer();
				mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 
				mMediaPlayer.setOnBufferingUpdateListener(this); 
				mMediaPlayer.setOnPreparedListener(this); 
			} catch (Exception e) {
				Log.e("mediaPlayer", "error", e);
			}
			mTimer.schedule(mTimerTask, 0, 1000);
		}
		TimerTask mTimerTask = new TimerTask() {
			@Override
			public void run() {
				if (mMediaPlayer == null)
					return;
				if (mMediaPlayer.isPlaying() && mSkbProgress.isPressed() == false) {
					handleProgress.sendEmptyMessage(0);
				}
			}
		};
		Handler handleProgress = new Handler() {
			public void handleMessage(Message msg) {
				int position = mMediaPlayer.getCurrentPosition();
				int duration = mMediaPlayer.getDuration();
				if (duration > 0) {
					long pos = mSkbProgress.getMax() * (position / duration);
					mSkbProgress.setProgress((int) pos);
				}
			};
		};
		public void play() {
			mMediaPlayer.start();
		}
		public void playUrl(String videoUrl) {
			try {
				mMediaPlayer.reset();
				mMediaPlayer.setDataSource(videoUrl);
				mMediaPlayer.prepare();
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalStateException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		public void pause() {
			mMediaPlayer.pause();
		}
		public void stop() {
			if (mMediaPlayer != null) {
				mMediaPlayer.stop();
				mMediaPlayer.release();
				mMediaPlayer = null;
			}
		}
		@Override
		public void onPrepared(MediaPlayer arg0) {
			arg0.start();
			Log.e("mediaPlayer", "onPrepared");
		}
		@Override
		public void onCompletion(MediaPlayer arg0) {
			Log.e("mediaPlayer", "onCompletion");
		}
		@Override
		public void onBufferingUpdate(MediaPlayer arg0, int bufferingProgress) {
			mSkbProgress.setSecondaryProgress(bufferingProgress);
			int currentProgress = mSkbProgress.getMax()
					* mMediaPlayer.getCurrentPosition()
					/ mMediaPlayer.getDuration();
			Log.e(currentProgress + "% play", bufferingProgress + "% buffer");
		}
	}
	<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<LinearLayout
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:layout_gravity="top"
			android:orientation="vertical" >
			<LinearLayout
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_gravity="center_horizontal"
				android:layout_marginTop="4.0dip"
				android:orientation="horizontal" >
				<Button
					android:id="@+id/btnPlayUrl"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:text="播放网络音频" >
				</Button>
				<Button
					android:id="@+id/btnPause"
					android:layout_width="80dip"
					android:layout_height="wrap_content"
					android:text="暂停" >
				</Button>
				<Button
					android:id="@+id/btnStop"
					android:layout_width="80dip"
					android:layout_height="wrap_content"
					android:text="停止" >
				</Button>
			</LinearLayout>
			<LinearLayout
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_marginBottom="20dip"
				android:orientation="horizontal" >
				<SeekBar
					android:id="@+id/skbProgress"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_gravity="center_vertical"
					android:layout_weight="1.0"
					android:max="100"
					android:paddingLeft="10dip"
					android:paddingRight="10dip" >
				</SeekBar>
			</LinearLayout>
		</LinearLayout>
	</FrameLayout>
//在线视频播放 
	public class MainActivity extends Activity {
		private SurfaceView mSurfaceView; 
		private Button mBtnPause; 
		private Button mBtnPlayUrl;
		private Button btnStop; 
		private SeekBar mSkbProgress;
		private Player mPlayer; 
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
			findView();
			setListener();
			mPlayer = new Player(mSurfaceView, mSkbProgress);
		}
		private void findView() {
			mSurfaceView = (SurfaceView) this.findViewById(R.id.surfaceView1);
			mBtnPlayUrl = (Button) this.findViewById(R.id.btnPlayUrl);
			btnStop = (Button) this.findViewById(R.id.btnStop);
			mSkbProgress = (SeekBar) this.findViewById(R.id.skbProgress);
		}
		private void setListener() {
			mBtnPlayUrl.setOnClickListener(new ClickEvent());
			mBtnPause = (Button) this.findViewById(R.id.btnPause);
			mBtnPause.setOnClickListener(new ClickEvent());
			btnStop.setOnClickListener(new ClickEvent());
			mSkbProgress.setOnSeekBarChangeListener(new SeekBarChangeEvent());
		}
		class ClickEvent implements OnClickListener {
			@Override
			public void onClick(View arg0) {
				if (arg0 == mBtnPause) {
					mPlayer.pause();
				} 
				else if (arg0 == mBtnPlayUrl) {
					String url = "http://www.baidupcs.com/file/9af1c0bb35d859d2a12d662e9f1e3a2a?xcode=7b41ea4ad01cdb81b102251452344002&fid=4228993954-250528-1406389171&time=1372147996&sign=FDTAXER-DCb740ccc5511e5e8fedcff06b081203-Gkxa8Rae7Lv1FQym0dJ8g66%2BuYg%3D&to=wb&fm=N,B,M&expires=8h&rt=sh&r=409944198&logid=2845104262&sh=1";
					mPlayer.playUrl(url);
				} 
				else if (arg0 == btnStop) {
					mPlayer.stop();
				}
			}
		}
		class SeekBarChangeEvent implements SeekBar.OnSeekBarChangeListener {
			int progress;
			@Override
			public void onProgressChanged(SeekBar seekBar, int progress,
					boolean fromUser) {
				this.progress = progress * mPlayer.mMediaPlayer.getDuration()
						/ seekBar.getMax();
			}
			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {

			}
			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {
				mPlayer.mMediaPlayer.seekTo(progress);
			}
		}
	}
	public class Player implements OnBufferingUpdateListener, OnCompletionListener,
		MediaPlayer.OnPreparedListener, SurfaceHolder.Callback {
		private int videoWidth;
		private int videoHeight;
		public MediaPlayer mMediaPlayer; 
		private SurfaceHolder mSurfaceHolder;
		private SeekBar mSkbProgress;
		private Timer mTimer = new Timer();
		public Player(SurfaceView surfaceView, SeekBar skbProgress) {
			this.mSkbProgress = skbProgress;
			mSurfaceHolder = surfaceView.getHolder();
			mSurfaceHolder.addCallback(this);
			mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
			mTimer.schedule(mTimerTask, 0, 1000);
		}
		TimerTask mTimerTask = new TimerTask() {
			@Override
			public void run() {
				if (mMediaPlayer == null)
					return;
				if (mMediaPlayer.isPlaying() && mSkbProgress.isPressed() == false) {
					handleProgress.sendEmptyMessage(0);
				}
			}
		};
		Handler handleProgress = new Handler() {
			public void handleMessage(Message msg) {
				int position = mMediaPlayer.getCurrentPosition();
				int duration = mMediaPlayer.getDuration();
				if (duration > 0) {
					long pos = mSkbProgress.getMax() * position / duration;
					mSkbProgress.setProgress((int) pos);
				}
			};
		};
		public void play() {
			mMediaPlayer.start();
		}
		public void playUrl(String videoUrl) {
			try {
				mMediaPlayer.reset();
				mMediaPlayer.setDataSource(videoUrl);
				mMediaPlayer.prepare();
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalStateException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		public void pause() {
			mMediaPlayer.pause();
		}
		public void stop() {
			if (mMediaPlayer != null) {
				mMediaPlayer.stop();
				mMediaPlayer.release();
				mMediaPlayer = null;
			}
		}
		@Override
		public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
			Log.e("mediaPlayer", "surface changed");
		}
		@Override
		public void surfaceCreated(SurfaceHolder arg0) {
			try {
				mMediaPlayer = new MediaPlayer();
				mMediaPlayer.setDisplay(mSurfaceHolder);
				mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
				mMediaPlayer.setOnBufferingUpdateListener(this);
				mMediaPlayer.setOnPreparedListener(this);
			} catch (Exception e) {
				Log.e("mediaPlayer", "error", e);
			}
		}
		@Override
		public void surfaceDestroyed(SurfaceHolder arg0) {
			Log.e("mediaPlayer", "surface destroyed");
		}
		@Override
		public void onPrepared(MediaPlayer arg0) {
			videoWidth = mMediaPlayer.getVideoWidth();
			videoHeight = mMediaPlayer.getVideoHeight();
			if (videoHeight != 0 && videoWidth != 0) {
				arg0.start();
			}
			Log.e("mediaPlayer", "onPrepared");
		}
		@Override
		public void onCompletion(MediaPlayer arg0) {
		}
		@Override
		public void onBufferingUpdate(MediaPlayer arg0, int bufferingProgress) {
			mSkbProgress.setSecondaryProgress(bufferingProgress);
			int currentProgress = mSkbProgress.getMax()
					* mMediaPlayer.getCurrentPosition()
					/ mMediaPlayer.getDuration();
			Log.e(currentProgress + "% play", bufferingProgress + "% buffer");
		}
	}
	<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
		<SurfaceView
			android:id="@+id/surfaceView1"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent" >
		</SurfaceView>
		<LinearLayout
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:layout_gravity="bottom"
			android:orientation="vertical" >
			<LinearLayout
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_gravity="center_horizontal"
				android:layout_marginTop="4.0dip"
				android:orientation="horizontal" >
				<Button
					android:id="@+id/btnPlayUrl"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:text="播放网络视频" >
				</Button>
				<Button
					android:id="@+id/btnPause"
					android:layout_width="80dip"
					android:layout_height="wrap_content"
					android:text="暂停" >
				</Button>
				<Button
					android:id="@+id/btnStop"
					android:layout_width="80dip"
					android:layout_height="wrap_content"
					android:text="停止" >
				</Button>
			</LinearLayout>
			<LinearLayout
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_marginBottom="20dip"
				android:orientation="horizontal" >
				<SeekBar
					android:id="@+id/skbProgress"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_gravity="center_vertical"
					android:layout_weight="1.0"
					android:max="100"
					android:paddingLeft="10dip"
					android:paddingRight="10dip" >
				</SeekBar>
			</LinearLayout>
		</LinearLayout>
	</FrameLayout>
//应用程序在线更新 
	<LinearLayout
  	xmlns:android="http://schemas.android.com/apk/res/android"
  	android:layout_width="fill_parent"
  	android:layout_height="wrap_content"
  	android:paddingLeft="5dip"
  	android:paddingRight="5dip"
  	android:orientation="vertical">  
		<ProgressBar
			android:id="@+id/update_progress"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			style="?android:attr/progressBarStyleHorizontal"/>
		<TextView 
			android:id="@+id/update_progress_text"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_gravity="right"
			android:textColor="@android:color/white"/>
	</LinearLayout>
	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >
		<Button
			android:id="@+id/btn"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:layout_alignParentLeft="true"
			android:text="在线更新" />
	</RelativeLayout>
	public class UpdateManager {
		private static final int DOWN_NOSDCARD = 0;
		private static final int DOWN_UPDATE = 1;
		private static final int DOWN_OVER = 2;
		private Context mContext;
		private Dialog downloadDialog;
		private ProgressBar mProgress;
		private TextView mProgressText;
		private int progress;
		private Thread downLoadThread;
		private boolean interceptFlag;
		private String apkUrl = "http://www.baidupcs.com/file/a8127065267221ea18df2554c2691c95?xcode=102ef5b132f96dff8c55e5d356906108&fid=4228993954-250528-879020187&time=1372165890&sign=FDTAXER-DCb740ccc5511e5e8fedcff06b081203-rCQ8so3ySZDjwU%2FavMB76KCDCw4%3D&to=wb&fm=N,B,G&expires=8h&rt=sh&r=362542044&logid=891789185&sh=1";
		private String savePath = "";
		private String apkFilePath = "";
		private String tmpFilePath = "";
		private String apkFileSize;
		private String tmpFileSize;
		public UpdateManager(Context context) {
			this.mContext = context;
		}
		private Handler mHandler = new Handler() {
			public void handleMessage(Message msg) {
				switch (msg.what) {
				case DOWN_UPDATE:
					mProgress.setProgress(progress);
					mProgressText.setText(tmpFileSize + "/" + apkFileSize);
					break;
				case DOWN_OVER:
					downloadDialog.dismiss();
					installApk();
					break;
				case DOWN_NOSDCARD:
					downloadDialog.dismiss();
					Toast.makeText(mContext, "无法下载安装文件,请检查SD卡是否挂载", 3000).show();
					break;
				}
			};
		};
		public void showDownloadDialog() {
			AlertDialog.Builder builder = new Builder(mContext);
			builder.setTitle("正在下载新版本");
			final LayoutInflater inflater = LayoutInflater.from(mContext);
			View v = inflater.inflate(R.layout.update_progress, null);
			mProgress = (ProgressBar) v.findViewById(R.id.update_progress);
			mProgressText = (TextView) v.findViewById(R.id.update_progress_text);
			builder.setView(v);
			builder.setNegativeButton("取消", new OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
					interceptFlag = true;
				}
			});
			builder.setOnCancelListener(new OnCancelListener() {
				@Override
				public void onCancel(DialogInterface dialog) {
					dialog.dismiss();
					interceptFlag = true;
				}
			});
			downloadDialog = builder.create();
			downloadDialog.setCanceledOnTouchOutside(false);
			downloadDialog.show();
			downloadApk();
		}
		private Runnable mdownApkRunnable = new Runnable() {
			@Override
			public void run() {
				try {
					String apkName = "wyl_" + ".apk";
					String tmpApk = "wyl_" + ".tmp";
					String storageState = Environment.getExternalStorageState();
					if (storageState.equals(Environment.MEDIA_MOUNTED)) {
						savePath = Environment.getExternalStorageDirectory()
								.getAbsolutePath() + "/Update/";
						File file = new File(savePath);
						if (!file.exists()) {
							file.mkdirs();
						}
						apkFilePath = savePath + apkName;
						tmpFilePath = savePath + tmpApk;
					}
					if (apkFilePath == null || apkFilePath == "") {
						mHandler.sendEmptyMessage(DOWN_NOSDCARD);
						return;
					}
					File ApkFile = new File(apkFilePath);
					if (ApkFile.exists()) {
						downloadDialog.dismiss();
						installApk();
						return;
					}
					File tmpFile = new File(tmpFilePath);
					FileOutputStream fos = new FileOutputStream(tmpFile);
					URL url = new URL(apkUrl);
					HttpURLConnection conn = (HttpURLConnection) url
							.openConnection();
					conn.connect();
					int length = conn.getContentLength();
					InputStream is = conn.getInputStream();
					DecimalFormat df = new DecimalFormat("0.00");
					apkFileSize = df.format((float) length / 1024 / 1024) + "MB";
					int count = 0;
					byte buf[] = new byte[1024];
					do {
						int numread = is.read(buf);
						count += numread;
						tmpFileSize = df.format((float) count / 1024 / 1024) + "MB";
						progress = (int) (((float) count / length) * 100);
						mHandler.sendEmptyMessage(DOWN_UPDATE);
						if (numread <= 0) {
							if (tmpFile.renameTo(ApkFile)) {
								mHandler.sendEmptyMessage(DOWN_OVER);
							}
							break;
						}
						fos.write(buf, 0, numread);
					} while (!interceptFlag);
					fos.close();
					is.close();
				} catch (MalformedURLException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		};
		private void downloadApk() {
			downLoadThread = new Thread(mdownApkRunnable);
			downLoadThread.start();
		}
		private void installApk() {
			File apkfile = new File(apkFilePath);
			if (!apkfile.exists()) {
				return;
			}
			Intent i = new Intent(Intent.ACTION_VIEW);
			i.setDataAndType(Uri.parse("file://" + apkfile.toString()),
					"application/vnd.android.package-archive");
			mContext.startActivity(i);
		}
	}
	public class MainActivity extends Activity {
		private Button mBtn; 
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			mBtn = (Button) findViewById(R.id.btn);
		}
		private void setListener() {
			mBtn.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					new UpdateManager(MainActivity.this).showDownloadDialog();
				}
			});
		}
	}
数据格式解析 
//DOM方式解析XML 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    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=".MainActivity" >
		<TextView
			android:id="@+id/textview"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:text="XML文件解析!" />
		<Button
			android:id="@+id/btnDom"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="DOM方式解析xml" />
	</LinearLayout>
	public class DOMPersonService {
		public static List<Person> readXml(InputStream inStream)
				throws ParserConfigurationException, SAXException, IOException {
			List<Person> persons = new ArrayList<Person>();
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
			DocumentBuilder builder = factory.newDocumentBuilder();
			Document document = builder.parse(inStream);
			Element root = document.getDocumentElement();
			NodeList nodes = root.getElementsByTagName("person");
			for (int i = 0; i < nodes.getLength(); i++) {
				Element personElement = (Element) nodes.item(i);
				Person person = new Person();
				person.setId(Integer.valueOf(personElement.getAttribute("id")));
				NodeList childNodes = personElement.getChildNodes();
				for (int j = 0; j < childNodes.getLength(); j++) {
					Node childNode = (Node) childNodes.item(j);
					if (childNode.getNodeType() == Node.ELEMENT_NODE) {
						Element childElement = (Element) childNode;
						if ("name".equals(childElement.getNodeName())) {
							person.setName(childElement.getFirstChild()
									.getNodeValue());
						} else if ("age".equals(childElement.getNodeName())) {
							person.setAge(new Short(childElement.getFirstChild()
									.getNodeValue()));
						}
					}
				}
				persons.add(person);
			}
			return persons;
		}
	}
	public class MainActivity extends Activity {
		private TextView mTvShow;  
		private Button mBtnDom; 
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			mBtnDom.setOnClickListener(myListener);
		}
		private void findView() {
			mTvShow = (TextView) findViewById(R.id.textview);
			mBtnDom = (Button) findViewById(R.id.btnDom);
		}
		private OnClickListener myListener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				InputStream inputStream = MainActivity.class.getClassLoader()
						.getResourceAsStream("people.xml");
				List<Person> persons = null;
				mTvShow.setText("");
				switch (v.getId()) {
				case R.id.btnDom:  
					mTvShow.setText("DOM:");
					try {
						persons = DOMPersonService.readXml(inputStream);
					} catch (ParserConfigurationException e) {
						e.printStackTrace();
					} catch (SAXException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}
					break;
				default:
					break;
				}
				for (Person person : persons) {
					mTvShow.setText(mTvShow.getText().toString() + "\n" + person.toString());
				}
			}
		};
	}
	public class Person {
		private Integer id;
		private String name;
		private Short age;
		public Person() {
			super();
		}
		public Person(Integer id, String name, Short age) {
			this.id = id;
			this.name = name;
			this.age = age;
		}
		public Integer getId() {
			return id;
		}
		public void setId(Integer id) {
			this.id = id;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public Short getAge() {
			return age;
		}
		public void setAge(Short age) {
			this.age = age;
		}
		@Override
		public String toString() {
			return "id = " + id + "name = " + name + "age = " + age;
		}
	}
	<persons xmlns:pre="http://www.baidu.com">
		<person id="001">
			<name>coolszy</name>
			<age>22</age>
		</person>
		<person id="002">
			<name>kuka</name>
			<age>23</age>
		</person> 
		<person id="003">
			<name>wyl</name>
			<age>30</age>
		</person> 
	</persons>
//SAX方式解析XML 
	<persons xmlns:pre="http://www.baidu.com">
		<person id="001">
			<name>coolszy</name>
			<age>22</age>
		</person>
		<person id="002">
			<name>kuka</name>
			<age>23</age>
		</person> 
		<person id="003">
			<name>wyl</name>
			<age>30</age>
		</person> 
	</persons>
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    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=".MainActivity" >
		<TextView
			android:id="@+id/textview"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:text="XML文件解析!" />
		<Button
			android:id="@+id/btnSAX"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="SAX方式解析xml" />
	</LinearLayout>
	public class XMLContentHandler extends DefaultHandler {
		public static final String TAG = "XMLContentHandler";
		private List<Person> persons;
		private Person person;
		private String preTag;
		public List<Person> getPersons() {
			return persons;
		}
		@Override
		public void startDocument() throws SAXException {
			super.startDocument();
			persons = new ArrayList<Person>();
			Log.i(TAG, "开始解析...");
		}
		@Override
		public void startElement(String uri, String localName, String qName,
				Attributes attributes) throws SAXException {
			super.startElement(uri, localName, qName, attributes);
			if ("person".equals(localName)) {
				person = new Person();
				person.setId(new Integer(attributes.getValue("id")));
			}
			preTag = localName;
			Log.i(TAG, "解析元素:" + localName);
		}
		@Override
		public void characters(char[] ch, int start, int length)
				throws SAXException {
			super.characters(ch, start, length);
			if (person != null) {
				String data = new String(ch, start, length);
				if ("name".equals(preTag)) {
					person.setName(data);
				} else if ("age".equals(preTag)) {
					person.setAge(new Short(data));
				}
			}
			Log.i(TAG, "解析的内容:" + new String(ch, start, length));
		}
		@Override
		public void endElement(String uri, String localName, String qName)
				throws SAXException {
			super.endElement(uri, localName, qName);
			if ("person".equals(localName) && person != null) {
				persons.add(person);
				person = null;
			}
			preTag = null;
			Log.i(TAG, localName + "解析完毕");
		}
		@Override
		public void endDocument() throws SAXException {
			super.endDocument();
			Log.i(TAG, "文档解析完毕");
		}
	}
	public class SAXPersonService {
		public static List<Person> readXml(InputStream inStream) throws ParserConfigurationException, SAXException, IOException{
			SAXParserFactory spf = SAXParserFactory.newInstance();
			SAXParser saxParser = spf.newSAXParser();
			XMLContentHandler handler = new XMLContentHandler();
			saxParser.parse(inStream, handler);
			inStream.close();
			return handler.getPersons();
		}
	}
	public class Person {
		private Integer id;
		private String name;
		private Short age;
		public Person() {
			super();
		}
		public Person(Integer id, String name, Short age) {
			this.id = id;
			this.name = name;
			this.age = age;
		}
		public Integer getId() {
			return id;
		}
		public void setId(Integer id) {
			this.id = id;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public Short getAge() {
			return age;
		}
		public void setAge(Short age) {
			this.age = age;
		}
		@Override
		public String toString() {
			return "id = " + id + "name = " + name + "age = " + age;
		}
	}
	public class MainActivity extends Activity {
		private TextView mTvShow;  	
		private Button mBtnSax;	
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			mBtnSax.setOnClickListener(myListener);
		}
		private void findView() {
			mTvShow = (TextView) findViewById(R.id.textview);
			mBtnSax = (Button) findViewById(R.id.btnSAX);
		}
		private OnClickListener myListener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				InputStream inputStream = MainActivity.class.getClassLoader()
						.getResourceAsStream("people.xml");
				List<Person> persons = null;
				mTvShow.setText("");
				switch (v.getId()) {
				case R.id.btnSAX:  
					mTvShow.setText("SAX:");
					try {
						persons = SAXPersonService.readXml(inputStream);
					} catch (ParserConfigurationException e) {
						e.printStackTrace();
					} catch (SAXException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}
					break;
				default:
					break;
				}
				for (Person person : persons) {
					mTvShow.setText(mTvShow.getText().toString() + "\n" + person.toString());
				}
			}
		};
	}
//PULL方式解析XML 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    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=".MainActivity" >
		<TextView
			android:id="@+id/textview"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:text="XML文件解析!" />
		<Button
			android:id="@+id/btnPull"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="Pull方式解析xml" />
	</LinearLayout>
	public class PullPersonService {
		public static List<Person> readXml(InputStream inStream)
				throws XmlPullParserException, IOException {
			List<Person> persons = null;
			XmlPullParser parser = Xml.newPullParser();
			parser.setInput(inStream, "UTF-8");     
			int eventCode = parser.getEventType();
			Person person = null;
			while (eventCode != XmlPullParser.END_DOCUMENT) {
				switch (eventCode) {
				case XmlPullParser.START_DOCUMENT:
					persons = new ArrayList<Person>();
					break;
				case XmlPullParser.START_TAG:
					if("person".equals(parser.getName())){
						person = new Person();
						person.setId(new Integer(parser.getAttributeValue(0)));
					}else if(null != person){
						if("name".equals(parser.getName())){
							person.setName(parser.nextText());
						}else if("age".equals(parser.getName())){ 
							person.setAge(new Short(parser.nextText()));
						}
					}
					break;
				case XmlPullParser.END_TAG:
					if("person".equals(parser.getName())&&person != null){
						persons.add(person);
						person = null;
					}
					break;
				}
				eventCode = parser.next();
			}
			return persons;
		}
	}
	public class Person {
		private Integer id;
		private String name;
		private Short age;
		public Person() {
			super();
		}
		public Person(Integer id, String name, Short age) {
			this.id = id;
			this.name = name;
			this.age = age;
		}
		public Integer getId() {
			return id;
		}
		public void setId(Integer id) {
			this.id = id;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public Short getAge() {
			return age;
		}
		public void setAge(Short age) {
			this.age = age;
		}
		@Override
		public String toString() {
			return "id = " + id + "name = " + name + "age = " + age;
		}
	}
	public class MainActivity extends Activity {
		private TextView mTvShow;  	
		private Button mBtnPull;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void setListener() {
			mBtnPull.setOnClickListener(myListener);
		}
		private void findView() {
			mTvShow = (TextView) findViewById(R.id.textview);
			mBtnPull = (Button) findViewById(R.id.btnPull);
		}
		private OnClickListener myListener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				InputStream inputStream = MainActivity.class.getClassLoader()
						.getResourceAsStream("people.xml");
				List<Person> persons = null;
				mTvShow.setText("");
				switch (v.getId()) {
				case R.id.btnPull:  
					mTvShow.setText("PULL:");
					try {
						persons = PullPersonService.readXml(inputStream);
					} catch (XmlPullParserException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}
					break;
				default:
					break;
				}
				for (Person person : persons) {
					mTvShow.setText(mTvShow.getText().toString() + "\n" + person.toString());
				}
			}
		};
	}
	<persons xmlns:pre="http://www.baidu.com">
		<person id="001">
			<name>coolszy</name>
			<age>22</age>
		</person>
		<person id="002">
			<name>kuka</name>
			<age>23</age>
		</person> 
		<person id="003">
			<name>wyl</name>
			<age>30</age>
		</person> 
	</persons>
//内置JSON解析 
	public class MainActivity extends Activity {
		private String json1 = "{\"url\":\"http://www.baidu.com\"}";
		private String json2 = "{\"name\":\"android\",\"version\":\"2.3.1\"}";
		private String jsonArray1 = "{\"namber\":[1,2,3]}";
		private String jsonArray2 = "{\"number\":[[zhangsan,18],[lisi,20],[wangwu,23]]}";
		private String jsonObj = "{\"mobile\":[{\"name\":\"android\"},{\"name\":\"iphone\"}]}";
		private Button btn1; 
		private Button btn2; 
		private Button btn3; 
		private Button btn4; 
		private Button btn5; 
		private TextView tv;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			btn1 = (Button) findViewById(R.id.btn1);
			btn2 = (Button) findViewById(R.id.btn2);
			btn3 = (Button) findViewById(R.id.btn3);
			btn4 = (Button) findViewById(R.id.btn4);
			btn5 = (Button) findViewById(R.id.btn5);
			tv = (TextView) findViewById(R.id.tv);
		}
		private void setListener() {
			btn1.setOnClickListener(mylistener);
			btn2.setOnClickListener(mylistener);
			btn3.setOnClickListener(mylistener);
			btn4.setOnClickListener(mylistener);
			btn5.setOnClickListener(mylistener);
		}
		private OnClickListener mylistener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn1: 
					JSONObject demoJson;
					String url;
					try {
						demoJson = new JSONObject(json1);
						url = demoJson.getString("url");
						tv.setText("url:" + url);
					} catch (JSONException e) {
						e.printStackTrace();
					}
					break;
				case R.id.btn2: 
					JSONObject demoJson2;
					try {
						demoJson2 = new JSONObject(json2);
						String name = demoJson2.getString("name");
						String version = demoJson2.getString("version");
						tv.setText("name:" + name + ",version" + version);
					} catch (JSONException e) {
						e.printStackTrace();
					}
					break;
				case R.id.btn3:
					JSONObject demoJson3;
					try {
						demoJson3 = new JSONObject(jsonArray1);
						JSONArray numberList = demoJson3.getJSONArray("namber");
						tv.setText("");
						for (int i = 0; i < numberList.length(); i++) {
							tv.setText(tv.getText() + "\n" + numberList.getInt(i));
						}
					} catch (JSONException e) {
						e.printStackTrace();
					}
					break;
				case R.id.btn4:
					JSONObject demoJson4;
					try {
						demoJson4 = new JSONObject(jsonArray2);
						JSONArray numberList = demoJson4.getJSONArray("number");
						tv.setText("");
						for (int i = 0; i < numberList.length(); i++) {
							tv.setText(tv.getText() + "\n"
									+ numberList.getJSONArray(i).getString(0) + ";"
									+ numberList.getJSONArray(i).getInt(1));
						}
					} catch (JSONException e) {
						e.printStackTrace();
					}
					break;
				case R.id.btn5: 
					JSONObject demoJson5;
					try {
						demoJson5 = new JSONObject(jsonObj);
						JSONArray numberList = demoJson5.getJSONArray("mobile");
						tv.setText("");
						for (int i = 0; i < numberList.length(); i++) {
							tv.setText(tv.getText() + "\n"
									+ numberList.getJSONObject(i).getString("name"));
						}
					} catch (JSONException e) {
						e.printStackTrace();
					}
					break;
				default:
					break;
				}
			}
		};
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    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=".MainActivity" >
		<TextView
			android:id="@+id/tv"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:text="Json数据解析" />
		<Button
			android:id="@+id/btn1"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="解析一个属性的对象" />
		<Button
			android:id="@+id/btn2"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="解析多个属性的对象" />
		<Button
			android:id="@+id/btn3"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="解析一个普通数组" />
		<Button
			android:id="@+id/btn4"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="解析一个嵌套数组" />
		<Button
			android:id="@+id/btn5"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="解析一个对象数组" />
	</LinearLayout>
//Gson解析JSON 
	 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    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=".MainActivity" >
		<TextView
			android:id="@+id/tv"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:text="Json数据解析" />
		<Button
			android:id="@+id/btn1"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="解析一个属性的对象" />
		<Button
			android:id="@+id/btn2"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="解析多个属性的对象" />
		<Button
			android:id="@+id/btn3"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="解析一个普通数组" />
		<Button
			android:id="@+id/btn4"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="解析一个嵌套数组" />
	</LinearLayout>
	public class Person {
		private String name;
		private int age;
		public Person() {
			super();
		}
		public Person(String name, int age) {
			super();
			this.name = name;
			this.age = age;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public int getAge() {
			return age;
		}
		public void setAge(int age) {
			this.age = age;
		}
		public String toString() {
			return "Person [name=" + name + ", age=" + age + "]";
		}
	}
	public class MainActivity extends Activity {
		private Button btn1; 
		private Button btn2; 
		private Button btn3; 
		private Button btn4; 
		private TextView tv;
		private Gson gson = new Gson();
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			btn1 = (Button) findViewById(R.id.btn1);
			btn2 = (Button) findViewById(R.id.btn2);
			btn3 = (Button) findViewById(R.id.btn3);
			btn4 = (Button) findViewById(R.id.btn4);
			tv = (TextView) findViewById(R.id.tv);
		}
		private void setListener() {
			btn1.setOnClickListener(mylistener);
			btn2.setOnClickListener(mylistener);
			btn3.setOnClickListener(mylistener);
			btn4.setOnClickListener(mylistener);
		}
		private OnClickListener mylistener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn1: 
					String json = "{\"name\":\"Wyl\",\"age\":30}";
					Person person = gson.fromJson(json, Person.class);
					tv.setText(person.toString());
					break;
				case R.id.btn2: 
					Person person1 = new Person("test", 20);
					String json_Person = gson.toJson(person1);
					tv.setText(json_Person);
					break;
				case R.id.btn3: 
					ArrayList<Person> persons = new ArrayList<Person>();
					Collections.addAll(persons, new Person("tom", 10), new Person(
							"jon", 20));
					String json_list = gson.toJson(persons);
					tv.setText(json_list);
					break;
				case R.id.btn4:
					String s = "[{\"name\":\"tom\",\"age\":10},{\"name\":\"jon\",\"age\":20}]";
					List<Person> retList = gson.fromJson(s,
							new TypeToken<List<Person>>() {
							}.getType());
					String t = "";
					for (Person p : retList) {
						t += p.toString();
					}
					tv.setText(t);
					break;
				default:
					break;
				}
			}
		};
	}
	
Android中的多媒体开发
Android中多媒体应用开发 
//屏幕方向改变 
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_orientation"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="改变屏幕方向" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button btnChangeScreen;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			btnChangeScreen = (Button) findViewById(R.id.btn_orientation);
		}
		private void setListener() {
			btnChangeScreen.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_orientation:
					if (MainActivity.this.getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {// 无法进行画面的旋转
						Toast.makeText(MainActivity.this, "无法改变屏幕方向",
								Toast.LENGTH_SHORT).show();
					} else {
						if (MainActivity.this.getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { // 现在的方向是横屏显示
							Toast.makeText(MainActivity.this, "已改变为竖屏方向",
									Toast.LENGTH_SHORT).show();
							setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
						} else if (MainActivity.this.getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { // 如果为竖屏显示
							Toast.makeText(MainActivity.this, "已改变为横屏方向",
									Toast.LENGTH_SHORT).show();
							setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // 变为横屏显示
						}
					}
					break;
				}
			}
		};
	}
//调用系统相机拍照 
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_takephoto"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="拍照" />
		<ImageView
			android:id="@+id/iv_image"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_gravity="center" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private static final int RESULT_CAPTURE_IMAGE = 1;
		private String strImgPath = "";// 照片文件绝对路径
		private Button btnTakePhoto;
		private ImageView ivSurface;
		private File out;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			btnTakePhoto = (Button) findViewById(R.id.btn_takephoto);
			ivSurface = (ImageView) findViewById(R.id.iv_image);
		}
		private void setListener() {
			btnTakePhoto.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_takephoto:
					cameraMethod();
					break;
				}
			}
		};
		private void cameraMethod() {
			Intent imageCaptureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
			strImgPath = Environment.getExternalStorageDirectory().toString()
					+ "/CONSDCGMPIC/";
			String fileName = new SimpleDateFormat("yyyyMMddHHmmss")
					.format(new Date()) + ".jpg";
			out = new File(strImgPath);
			if (!out.exists()) {
				out.mkdirs();
			}
			out = new File(strImgPath, fileName);
			strImgPath = strImgPath + fileName;
			startActivityForResult(imageCaptureIntent, RESULT_CAPTURE_IMAGE);
		}
		@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			super.onActivityResult(requestCode, resultCode, data);
			switch (requestCode) {
			case RESULT_CAPTURE_IMAGE:
				if (resultCode == RESULT_OK) {
					Bundle extras = data.getExtras();
					Bitmap b = (Bitmap) extras.get("data");
					Matrix matrix = new Matrix();
					matrix.postScale(5f, 4f);
					b = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(),
							matrix, true);
					ivSurface.setImageBitmap(b);
					try {
						FileOutputStream outStream = new FileOutputStream(out);
						b.compress(CompressFormat.JPEG, 100, outStream);
						outStream.close();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				break;
			}
		}
	}
//录音机 
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_startvoicerecoding"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开始录音" />
		<Button
			android:id="@+id/btn_stopvoicerecoding"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="停止录音" />
	</LinearLayout>
	public class MainActivity extends Activity {
		private Button recordButton;
		private Button stopButton;
		private MediaRecorder mr;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			recordButton = (Button) this.findViewById(R.id.btn_startvoicerecoding);
			stopButton = (Button) this.findViewById(R.id.btn_stopvoicerecoding);
		}
		private void setListener() {
			recordButton.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					File file = new File("/sdcard/"
							+ "YY"
							+ new DateFormat().format("yyyyMMdd_hhmmss",
									Calendar.getInstance(Locale.CHINA)) + ".amr");
					Toast.makeText(getApplicationContext(),
							"正在录音,录音文件在" + file.getAbsolutePath(),
							Toast.LENGTH_LONG).show();
					mr = new MediaRecorder();
					mr.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
					mr.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
					mr.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
					mr.setOutputFile(file.getAbsolutePath());
					try {
						file.createNewFile();
						mr.prepare();
					} catch (IllegalStateException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}
					mr.start();
					recordButton.setText("录音中……");
				}
			});
			stopButton.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					if (mr != null) {
						mr.stop();
						mr.release();
						mr = null;
						recordButton.setText("录音");
						Toast.makeText(getApplicationContext(), "录音完毕",
								Toast.LENGTH_LONG).show();
					}
				}
			});
		}
	}
//录像机 
	public class MainActivity extends Activity implements SurfaceHolder.Callback {
		private Button start;
		private Button stop;
		private MediaRecorder mediarecorder;
		private SurfaceView surfaceview;
		private SurfaceHolder surfaceHolder;
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			requestWindowFeature(Window.FEATURE_NO_TITLE);
			getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
					WindowManager.LayoutParams.FLAG_FULLSCREEN);
			setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
			getWindow().setFormat(PixelFormat.TRANSLUCENT);
			setContentView(R.layout.activity_main);
			init();
		}
		private void init() {
			start = (Button) this.findViewById(R.id.start);
			stop = (Button) this.findViewById(R.id.stop);
			start.setOnClickListener(new TestVideoListener());
			stop.setOnClickListener(new TestVideoListener());
			surfaceview = (SurfaceView) this.findViewById(R.id.surfaceview);
			SurfaceHolder holder = surfaceview.getHolder();
			holder.addCallback(this);
			holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
		}
		class TestVideoListener implements OnClickListener {
			@Override
			public void onClick(View v) {
				if (v == start) {
					mediarecorder = new MediaRecorder();
					mediarecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
					mediarecorder
							.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
					mediarecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
					mediarecorder.setVideoSize(176, 144);
					mediarecorder.setVideoFrameRate(20);
					mediarecorder.setPreviewDisplay(surfaceHolder.getSurface());
					mediarecorder.setOutputFile("/sdcard/wyl.3gp");
					try {
						mediarecorder.prepare();
						mediarecorder.start();
					} catch (IllegalStateException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
				if (v == stop) {
					if (mediarecorder != null) {
						mediarecorder.stop();
						mediarecorder.release();
						mediarecorder = null;
					}
				}
			}
		}
		@Override
		public void surfaceChanged(SurfaceHolder holder, int format, int width,
				int height) {
			surfaceHolder = holder;
		}
		@Override
		public void surfaceCreated(SurfaceHolder holder) {
			surfaceHolder = holder;
		}
		@Override
		public void surfaceDestroyed(SurfaceHolder holder) {
			surfaceview = null;
			surfaceHolder = null;
			mediarecorder = null;
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
		<LinearLayout
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:layout_weight="1" >
			<SurfaceView
				android:id="@+id/surfaceview"
				android:layout_width="fill_parent"
				android:layout_height="fill_parent" />
		</LinearLayout>
		<LinearLayout
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:layout_weight="4"
			android:gravity="center"
			android:orientation="vertical" >
			<Button
				android:id="@+id/start"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="Start" />
			<Button
				android:id="@+id/stop"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="Stop" />
		</LinearLayout>
	</LinearLayout>
//手电筒应用 
	public class MainActivity extends Activity {
		private Button btnLight;
		private Camera m_Camera;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			btnLight = (Button) findViewById(R.id.btn_open);
		}
		private void setListener() {
			btnLight.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_open:
					if (isSupposeFlashLight()) {
						if (null == m_Camera) {
							m_Camera = Camera.open();
							Camera.Parameters parameters = m_Camera.getParameters();
							parameters
									.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
							m_Camera.setParameters(parameters);
							m_Camera.startPreview();
							btnLight.setText("关闭手电筒");
							Toast.makeText(MainActivity.this, "手电筒已打开",
									Toast.LENGTH_SHORT).show();
						} else {
							m_Camera.stopPreview();
							m_Camera.release();
							m_Camera = null;
							btnLight.setText("打开手电筒");
							Toast.makeText(MainActivity.this, "手电筒已关闭",
									Toast.LENGTH_SHORT).show();
						}
					} else {
						Toast.makeText(MainActivity.this, "您的设备不支持闪光灯",
								Toast.LENGTH_SHORT).show();
					}
					break;
				}
			}
		};
		public Boolean isSupposeFlashLight() {
			PackageManager pm = this.getPackageManager();
			FeatureInfo[] features = pm.getSystemAvailableFeatures();
			for (FeatureInfo f : features) {
				if (PackageManager.FEATURE_CAMERA_FLASH.equals(f.name)) // 判断设备是否支持闪光灯
				{
					return true;
				}
			}
			return false;
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_open"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="打开手电筒" />
	</LinearLayout>
//计时器 
	public class MainActivity extends Activity {
		private int startTime = 0;
		private Chronometer chronometer;
		private Button btnOperate;
		private Button btnRest;
		private EditText edtSetTime;
		private Boolean boolOperate = true;
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			// TODO Auto-generated method stub
			chronometer = (Chronometer) findViewById(R.id.chronometer);
			btnOperate = (Button) findViewById(R.id.btntimeopp);
			btnRest = (Button) findViewById(R.id.btnReset);
			edtSetTime = (EditText) findViewById(R.id.edt_settime);
		}
		private void setListener() {
			// TODO Auto-generated method stub
			btnRest.setOnClickListener(listener);
			btnOperate.setOnClickListener(listener);
			chronometer
					.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
						@Override
						public void onChronometerTick(Chronometer chronometer) {
							if (SystemClock.elapsedRealtime()
									- chronometer.getBase() > startTime * 1000) {
								chronometer.stop();
								showDialog();
							}
						}
					});
		}
		OnClickListener listener = new OnClickListener() {

			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btntimeopp:
					if (boolOperate) {
						String ss = edtSetTime.getText().toString();
						if (!(ss.equals("") && ss != null)) {
							startTime = Integer.parseInt(edtSetTime.getText()
									.toString());
						}
						chronometer.setBase(SystemClock.elapsedRealtime());
						chronometer.start();
						boolOperate = false;
						edtSetTime.setClickable(false);
						btnOperate.setText("点击停止");
					}
					else {
						chronometer.stop();
						boolOperate = true;
						edtSetTime.setClickable(true);
						btnOperate.setText("点击开始");
					}
					break;
				case R.id.btnReset:
					chronometer.setBase(SystemClock.elapsedRealtime());
					break;
				default:
					break;
				}
			}
		};
		protected void showDialog() {
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setIcon(R.drawable.ic_launcher);
			builder.setTitle("警告").setMessage("时间到")
					.setPositiveButton("确定", new DialogInterface.OnClickListener() {
						@Override
						public void onClick(DialogInterface dialog, int which) {
						}
					});
			AlertDialog dialog = builder.create();
			dialog.show();
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical" >
		<LinearLayout
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:layout_margin="10dip"
			android:orientation="horizontal" >
			<TextView
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_weight="4"
				android:gravity="center"
				android:text="设置时间:" />
			<EditText
				android:id="@+id/edt_settime"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:inputType="number" />
		</LinearLayout>
		<Chronometer
			android:id="@+id/chronometer"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:gravity="center"
			android:textColor="#ff0000"
			android:textSize="60dip" />
		<LinearLayout
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:layout_margin="10dip"
			android:orientation="horizontal" >
			<Button
				android:id="@+id/btntimeopp"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="开始记时" />
			<Button
				android:id="@+id/btnReset"
				android:layout_width="fill_parent"
				android:layout_height="wrap_content"
				android:layout_weight="1"
				android:text="重置" />
		</LinearLayout>
	</LinearLayout>
//语音识别功能 
	public class MainActivity extends Activity {
		private Button btnReconizer;
		private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			btnReconizer = (Button) findViewById(R.id.btn_open);
		}
		private void setListener() {
			btnReconizer.setOnClickListener(listener);
		}
		OnClickListener listener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btn_open:
					try {
						Intent intent = new Intent(
								RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
						intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
								RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
						intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "开始语音");
						startActivityForResult(intent,
								VOICE_RECOGNITION_REQUEST_CODE);
					} catch (Exception e) {
						e.printStackTrace();
						Toast.makeText(getApplicationContext(), "找不到语音设备", 1)
								.show();
					}
					break;
				}
			}
		};
		@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			if (requestCode == VOICE_RECOGNITION_REQUEST_CODE
					&& resultCode == RESULT_OK) {
				ArrayList<String> results = data
						.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
				String resultString = "";
				for (int i = 0; i < results.size(); i++) {
					resultString += results.get(i);
				}
				Toast.makeText(this, resultString, 1).show();
			}
			super.onActivityResult(requestCode, resultCode, data);
		}
	}
	<LinearLayout 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:orientation="vertical" >
		<Button
			android:id="@+id/btn_open"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开始语音识别" />
	</LinearLayout>
//语音转换文本 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView1"
    android:layout_toLeftOf="@+id/textView1"
    android:gravity="center"
    android:orientation="vertical" >
		<Button
			android:id="@+id/btnSpeak"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:layout_margin="10dp"
			android:layout_marginRight="10dp"
			android:layout_marginTop="10dp"
			android:text="speak"
			/>
		<TextView
			android:id="@+id/txtText"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_marginLeft="10dp"
			android:layout_marginRight="10dp"
			android:layout_marginTop="10dp"
			android:textAppearance="?android:attr/textAppearanceLarge"
			android:text="此处将你所说的话转化为文本显示出来" />
	</LinearLayout>
	public class MainActivity extends Activity {
		protected static final int RESULT_SPEECH = 1;
		private Button btnSpeak;
		private TextView txtText;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			findView();
			setListener();
		}
		private void findView() {
			txtText = (TextView) findViewById(R.id.txtText);
			btnSpeak = (Button) findViewById(R.id.btnSpeak);
		}
		private void setListener() {
			btnSpeak.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent intent = new Intent(
							RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
					intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");
					try {
						startActivityForResult(intent, RESULT_SPEECH);
						txtText.setText("");
					} catch (ActivityNotFoundException a) {
						Toast t = Toast.makeText(getApplicationContext(),
								"您的手机不支持Speech to Text功能",
								Toast.LENGTH_SHORT);
						t.show();
					}
				}
			});
		}
		@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			super.onActivityResult(requestCode, resultCode, data);
			switch (requestCode) {
			case RESULT_SPEECH:
				if (resultCode == RESULT_OK && null != data) {
					ArrayList<String> text = data
							.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
					txtText.setText(text.get(0));
				}
				break;
			}
		}
	}
//TTS文字朗读 
	public class MainActivity extends Activity implements OnInitListener {
		private EditText inputText = null;
		private Button speakBtn = null;
		private static final int REQ_TTS_STATUS_CHECK = 0;
		private static final String TAG = "TTS Demo";
		private TextToSpeech mTts;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			Intent checkIntent = new Intent();
			checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
			startActivityForResult(checkIntent, REQ_TTS_STATUS_CHECK);
			findView();
			setListener();
		}
		private void setListener() {
			speakBtn.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {
					mTts.speak(inputText.getText().toString(),
							TextToSpeech.QUEUE_ADD, null);
				}
			});
		}
		private void findView() {
			inputText = (EditText) findViewById(R.id.inputText);
			speakBtn = (Button) findViewById(R.id.speakBtn);
			inputText.setText("hello world.");
		}
		@Override
		public void onInit(int status) {
			if (status == TextToSpeech.SUCCESS) {
				int result = mTts.setLanguage(Locale.US);
				if (result == TextToSpeech.LANG_MISSING_DATA
						|| result == TextToSpeech.LANG_NOT_SUPPORTED)
				{
					Log.v(TAG, "Language is not available");
					speakBtn.setEnabled(false);
				} else {
					mTts.speak("This is an example of speech synthesis.",
							TextToSpeech.QUEUE_ADD, null);
					speakBtn.setEnabled(true);
				}
			}
		}
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			if (requestCode == REQ_TTS_STATUS_CHECK) {
				switch (resultCode) {
				case TextToSpeech.Engine.CHECK_VOICE_DATA_PASS:
				{
					mTts = new TextToSpeech(this, this);
					Log.v(TAG, "TTS Engine is installed!");
				}
					break;
				case TextToSpeech.Engine.CHECK_VOICE_DATA_BAD_DATA:
				case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_DATA:
				case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_VOLUME:
				{
					Log.v(TAG, "Need language stuff:" + resultCode);
					Intent dataIntent = new Intent();
					dataIntent
							.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
					startActivity(dataIntent);

				}
					break;
				case TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL:
				default:
					Log.v(TAG, "Got a failure. TTS apparently not available");
					break;
				}
			} else {
			}
		}
		@Override
		protected void onPause() {
			super.onPause();
			if (mTts != null)
			{
				mTts.stop();
			}
		}
		@Override
		protected void onDestroy() {
			super.onDestroy();
			mTts.shutdown();
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<EditText
			android:id="@+id/inputText"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:hint="Input the text here!" >
		</EditText>
		<Button
			android:id="@+id/speakBtn"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_gravity="center_horizontal"
			android:enabled="false"
			android:text="Speak" >
		</Button>
	</LinearLayout>
//本地音频播放 
	public class MainActivity extends Activity {
		private Button BtnStart;
		private Button BtnPause;
		private Button BtnStop;
		private MediaPlayer player = new MediaPlayer();
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.main);
			try {
				player.setDataSource("/sdcard/test.mp3");
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalStateException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			findView();
			setListener();
		}
		private void setListener() {
			BtnStart.setOnClickListener(mylistener);
			BtnPause.setOnClickListener(mylistener);
			BtnStop.setOnClickListener(mylistener);
		}
		private void findView() {
			BtnStart = (Button) findViewById(R.id.BtnStart);
			BtnPause = (Button) findViewById(R.id.BtnPause);
			BtnStop = (Button) findViewById(R.id.BtnStop);
		}
		OnClickListener mylistener = new OnClickListener() {
			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.BtnStart:
					try {
						player.prepare();
					} catch (IllegalStateException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}
					player.start();
					break;
				case R.id.BtnPause:
					player.pause();
					break;
				case R.id.BtnStop:
					player.seekTo(0);
					player.stop();
					try {
						player.prepare();
					} catch (IllegalStateException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}
					break;
				default:
					break;
				}
			}
		};
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
		<Button
			android:id="@+id/BtnStart"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="开始" />
		<Button
			android:id="@+id/BtnPause"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="暂停" />
		<Button
			android:id="@+id/BtnStop"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:text="停止" />
	</LinearLayout>
//音效播放 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
		<Button
			android:id="@+id/BtnPlay"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="Play" />
		<Button
			android:id="@+id/BtnMore"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="More" />
	</LinearLayout>
	public class MainActivity extends Activity implements View.OnClickListener,
			SoundPool.OnLoadCompleteListener {
		static String TAG = "TestSoundPoolActivity";
		private SoundPool sndPool;
		private static final int SOUND_LOAD_OK = 1;
		private final Handler mHandler = new MyHandler();
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.main);
			findView();
			sndPool = new SoundPool(16, AudioManager.STREAM_MUSIC, 0);
			sndPool.setOnLoadCompleteListener(this);
		}
		private void findView() {
			Button b1 = (Button) findViewById(R.id.BtnPlay);
			b1.setOnClickListener(this);
			b1 = (Button) findViewById(R.id.BtnMore);
			b1.setOnClickListener(this);
		}
		public void onDestroy() {
			sndPool.release();
			super.onDestroy();
		}
		private class MyHandler extends Handler {
			public void handleMessage(Message msg) {
				switch (msg.what) {
				case SOUND_LOAD_OK:
					sndPool.play(msg.arg1, (float) 0.8, (float) 0.8, 16, 10,
							(float) 1.0);
					break;
				}
			}
		}
		public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
			Message msg = mHandler.obtainMessage(SOUND_LOAD_OK);
			msg.arg1 = sampleId;
			mHandler.sendMessage(msg);
		}
		public void onClick(View v) {
			int id = v.getId();
			switch (id) {
			case R.id.BtnPlay:
				if (sndPool != null)
					sndPool.load(this, R.raw.f, 1);
				break;
			case R.id.BtnMore:
				sndPool.load(this, R.raw.f, 1);
				Log.v(TAG, "more");
				break;
			}
		}
	}
//播放本地视频 
	public class MainActivity extends Activity implements
			MediaPlayer.OnErrorListener, 
			MediaPlayer.OnCompletionListener {
		public static final String TAG = "VideoPlayer";
		private VideoView mVideoView;
		private Uri mUri;
		private int mPositionWhenPaused = -1;
		private MediaController mMediaController;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
			mVideoView = (VideoView) findViewById(R.id.videoview);
			mUri = Uri.parse(Environment.getExternalStorageDirectory()
					+ "/video.3gp");
			mMediaController = new MediaController(this);
			mVideoView.setMediaController(mMediaController);
		}
		@Override
		public boolean onError(MediaPlayer mp, int what, int extra) {
			return false;
		}
		@Override
		public void onCompletion(MediaPlayer mp) {
			this.finish();
		}
		public void onStart() {
			mVideoView.setVideoURI(mUri);
			mVideoView.start();
			super.onStart();
		}
		public void onPause() {
			mPositionWhenPaused = mVideoView.getCurrentPosition();
			mVideoView.stopPlayback();
			super.onPause();
		}
		public void onResume() {
			if (mPositionWhenPaused >= 0) {
				mVideoView.seekTo(mPositionWhenPaused);
				mPositionWhenPaused = -1;
			}
			super.onResume();
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
		<VideoView
			android:id="@+id/videoview"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:layout_centerInParent="true" />
	</LinearLayout>
//加速度传感器应用 
	public class MainActivity extends Activity {
		private TextView Tv;
		private SensorManager sm;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			sm = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
			findView();
		}
		@Override
		protected void onResume() {
			super.onResume();
			sm.registerListener(sel,
					sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), 
					SensorManager.SENSOR_DELAY_UI);
		}
		@Override
		protected void onStop() {
			sm.unregisterListener(sel);
			super.onStop();
		}
		SensorEventListener sel = new SensorEventListener() {
			@Override
			public void onSensorChanged(SensorEvent event) {
				// TODO Auto-generated method stub
				String str;
				str = "X方向的加速度是:"+event.values[0];
				str += "\nY方向的加速度是:"+event.values[1];
				str += "\nZ方向的加速度是:"+event.values[2];
				Tv.setText(str);
			}
			@Override
			public void onAccuracyChanged(Sensor sensor, int accuracy) {
			}
		};
		private void findView() {
			Tv = (TextView) findViewById(R.id.Tv);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content" />
	</LinearLayout>
//光强度查看器 
	public class MainActivity extends Activity {
		private TextView Tv;
		private SensorManager sm;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			sm = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
			findView();
		}
		@Override
		protected void onResume() {
			super.onResume();
			sm.registerListener(sel,
					sm.getDefaultSensor(Sensor.TYPE_LIGHT),  
					SensorManager.SENSOR_DELAY_FASTEST);  
		}
		@Override
		protected void onStop() {
			sm.unregisterListener(sel);
			super.onStop();
		}
		SensorEventListener sel = new SensorEventListener() {
			@Override
			public void onSensorChanged(SensorEvent event) {
				String str;
				str = "当前的手机范围内的光强度为:"+event.values[0];
				Tv.setText(str);
			}
			@Override
			public void onAccuracyChanged(Sensor sensor, int accuracy) {
				
			}
		};
		private void findView() {
			Tv = (TextView) findViewById(R.id.Tv);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content" />
	</LinearLayout>
//微信摇一摇功能 
	public class MainActivity extends Activity {
		private TextView Tv;
		private SensorManager sm;
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
			findView();
		}
		@Override
		protected void onResume() {
			super.onResume();

			sm.registerListener(sel,
					sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
					SensorManager.SENSOR_DELAY_UI);
		}

		@Override
		protected void onStop() {
			sm.unregisterListener(sel);
			super.onStop();
		}
		SensorEventListener sel = new SensorEventListener() {
			@Override
			public void onSensorChanged(SensorEvent event) {
				int sensorType = event.sensor.getType();
				float[] values = event.values;
				if (sensorType == Sensor.TYPE_ACCELEROMETER) {
					if (Math.abs(values[0]) > 14 || Math.abs(values[1]) > 14
							|| Math.abs(values[2]) > 14) {
						Tv.setText("您摇到一位好友");
					}
				}
			}
			@Override
			public void onAccuracyChanged(Sensor sensor, int accuracy) {

			}
		};
		private void findView() {
			Tv = (TextView) findViewById(R.id.Tv);
		}
	}
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
		<TextView
			android:id="@+id/Tv"
			android:layout_width="match_parent"
			android:layout_height="wrap_content"
			android:textSize="20sp"
			android:text="请摇动手机得到一位好友!" />
	</LinearLayout>
桌面插件开发 	
//切换壁纸插件 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
		<Button android:id="@+id/btn"
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:gravity="center"
			android:background="@drawable/ic_launcher"/>
		<TextView
			android:layout_width="fill_parent"
			android:layout_height="wrap_content"
			android:text="切换壁纸"/>
	</LinearLayout>
	public class AppWidet extends AppWidgetProvider {
		private static final String CLICK_NAME_ACTION = "com.wyl.action.widget.click";
		private RemoteViews myRemoteViews;
		private static int clickTime;
		private int[] images = { R.raw.image_01, R.raw.image_02, R.raw.image_03,
				R.raw.image_04, R.raw.image_05 };
		private InputStream is;
		@Override
		public void onUpdate(Context context, AppWidgetManager appWidgetManager,
				int[] appWidgetIds) {
			updateAppWidget(context, appWidgetManager);
		}
		public void updateAppWidget(Context context, AppWidgetManager appWidgeManger) {
			myRemoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
			Intent intentClick = new Intent(CLICK_NAME_ACTION);
			PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0,
					intentClick, 0);
			myRemoteViews.setOnClickPendingIntent(R.id.btn, pendingIntent);
			ComponentName myComponentName = new ComponentName(context,
					AppWidet.class);
			AppWidgetManager myAppWidgetManager = AppWidgetManager
					.getInstance(context);
			myAppWidgetManager.updateAppWidget(myComponentName, myRemoteViews);
		}
		@Override
		public void onDeleted(Context context, int[] appWidgetIds) {
			System.out.println("onDeleted");
			super.onDeleted(context, appWidgetIds);
		}
		@Override
		public void onEnabled(Context context) {
			System.out.println("onEnabled");
			super.onEnabled(context);
		}
		@Override
		public void onDisabled(Context context) {
			System.out.println("onDisabled");
			super.onDisabled(context);
		}
		@Override
		public void onReceive(Context context, Intent intent) {
			System.out.println("onReceive");
			super.onReceive(context, intent);
			if (myRemoteViews == null) {
				myRemoteViews = new RemoteViews(context.getPackageName(),
						R.layout.main);
			}
			if (intent.getAction().equals(CLICK_NAME_ACTION)) {
				Log.e("CLICK_NAME_ACTION", clickTime + "");
				if (clickTime < images.length) {
					Resources resources = context.getResources();
					is = resources.openRawResource(images[clickTime]);
					try {
						context.setWallpaper(is);
						Toast.makeText(context, "桌面壁纸已切换", Toast.LENGTH_SHORT)
								.show();
					} catch (Exception e) {
						e.printStackTrace();
					}
					clickTime++;
					if (clickTime >= images.length  ) {
						clickTime = 0;
					}
				} else {
					Toast.makeText(context, "桌面壁纸已换完", Toast.LENGTH_SHORT).show();
				}
				AppWidgetManager appWidgetManger = AppWidgetManager
						.getInstance(context);
				int[] appIds = appWidgetManger.getAppWidgetIds(new ComponentName(
						context, AppWidet.class));
				appWidgetManger.updateAppWidget(appIds, myRemoteViews);
			}
		}
	}
//倒计时插件 
	<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="wrap_content"
    android:layout_height="fill_parent">
		<TextView android:id="@+id/text"
			android:layout_width="wrap_content"
			android:layout_height="fill_parent"
			android:singleLine="false"
			android:gravity="center"
			android:textSize="17dip"
			android:textColor="#FF0000"
			android:layout_marginLeft="5dip"
			android:layout_marginRight="5dip"
			android:background="@drawable/text"/>
	</LinearLayout>
	public class AppWidet extends AppWidgetProvider {
		private static final String CLICK_NAME_ACTION = "com.wyl.action.widget.click";
		private  RemoteViews myRemoteViews;
		@Override
		public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
			Timer timer=new Timer();
			timer.scheduleAtFixedRate(new MyTime(context, appWidgetManager), 1, 60000);
			super.onUpdate(context, appWidgetManager, appWidgetIds);
		}
		@Override
		public void onDeleted(Context context, int[] appWidgetIds) {
			System.out.println("onDeleted");
			super.onDeleted(context, appWidgetIds);
		}
		@Override
		public void onEnabled(Context context) {
			System.out.println("onEnabled");
			super.onEnabled(context);
		}
		@Override
		public void onDisabled(Context context) {
			System.out.println("onDisabled");
			super.onDisabled(context);
		}
		@Override
		public void onReceive(Context context, Intent intent) {
			System.out.println("onReceive");
			super.onReceive(context, intent);
		   
		}
		private class MyTime extends TimerTask{  
			RemoteViews remoteViews;  
			AppWidgetManager appWidgetManager;  
			ComponentName thisWidget;  
			public MyTime(Context context,AppWidgetManager appWidgetManager){  
				this.appWidgetManager = appWidgetManager;
				remoteViews = new RemoteViews(context.getPackageName(),R.layout.main); 
				thisWidget = new ComponentName(context,AppWidet.class);  
			}  
			public void run() {  
				Date date = new Date();
				Calendar calendar = new GregorianCalendar(2013,10,01);  
				long days = (((calendar.getTimeInMillis()-date.getTime())/1000))/86400;  
				remoteViews.setTextViewText(R.id.text, "距离期末考试还有" + days+"天");  
				appWidgetManager.updateAppWidget(thisWidget, remoteViews);  
			}  
		}  
	}

 

© 著作权归作者所有

MoreYoungG
粉丝 19
博文 26
码字总数 440790
作品 0
广州
私信 提问
有奖征文004期|从小白到大牛,进阶路上有话说?

从小白到大牛,是用无数代码堆砌出的血泪史,就问你,想不想一吐为快? 想不想让大家了解你和代码那些风花雪月的故事? 或独自一人用青春和热血挥洒代码的经历? 咳咳,其实就是想让你写写程...

慕课网官方_运营中心
2018/05/29
0
0
小白学phoneGap《构建跨平台APP:phoneGap移动应用实战》连载三(通过实例来体验生命周

4.1.2 通过实例来亲身体验Activity的生命周期 上一小节介绍了Activity生命周期中的各个过程,本小节将以一个简单的实例来使读者亲身体验到Activity生命周期中的各个事件。 在Eclipse中新建一...

woiwoi
2014/10/29
0
2
一周福利 | 安装OneAPM Android SDK 送你一本你最想读的书!

移动应用遇到的5大问题: 1、 运行过程中出现强制关闭;2、生产环境下出现HTTP错误;3、响应时间过长; 4、 页面元素加载缓、慢卡顿;5、不同地区响应时间有所差异 都是性能惹的祸! 谁说性能...

OneAPM蓝海讯通
2015/11/12
1K
14
微信开放平台开发工具包(SDK)

iOS开发工具包 开发工具包(SDK) 使用微信分享、登录、收藏、支付等功能需要的库以及文件。点击下载iOS开发工具包64位 使用微信语音识别接口、语音合成接口。点击下载 语音SDK+Demo+开发文档...

雪深
2015/02/05
0
0
Android源码50例汇总,欢迎各位下载

下载中心好资料很多,藏在各个角落,小弟在此帮大家做了一个整理,做了一个下载目录,方便大家选择性下载。 源码实例如下: 《Android应用开发揭秘》源代码推荐 http://down.51cto.com/data...

程序袁_绪龙
2015/01/23
0
0

没有更多内容

加载失败,请刷新页面

加载更多

Java中print、printf、println的区别

printf主要是继承了C语言的printf的一些特性,可以进行格式化输出 print就是一般的标准输出,但是不换行 println和print基本没什么差别,就是最后会换行

hellation_
14分钟前
0
0
spring在静态类中注入bean的的解释

@Componentpublic class ModelMapper {@AutoWiredprivate static AssignmentManager assignmentManager;public static void add(){a+b;}} 静态方法是属于类的,普通方法才属于...

无知的小狼
14分钟前
0
0
分而治之-归并排序

如果有1个数组,数组的左半部分和右半部分都已经排好序,如何将该数组合成1个有序的数组? 开辟1个同样大小的临时空间辅助我们完成归并过程,如下图 k:表示归并过程中,当前需要替换的原数组...

万山红遍
28分钟前
0
0
Linux修改时区的正确方法【修改时间,需要修改软连接,靠谱】

CentOS和Ubuntu的时区文件是/etc/localtime,但是在CentOS7以后localtime以及变成了一个链接文件 [root@centos7 ~]# ll /etc/localtime lrwxrwxrwx 1 root root 33 Oct 12 11:01 /etc/loca......

Airship
今天
1
0
《Netkiller Spring Cloud 手札》之 Master / Slave 主从数据库数据源配置

5.19.1. Master / Slave 主从数据库数据源配置 5.19.1.1. application.properties spring.datasource.master.driverClassName = com.mysql.cj.jdbc.Driverspring.datasource.master.url=j......

netkiller-
今天
50
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部