android控件18 ImageSwitcher
来源:互联网 发布:java开发的项目 编辑:程序博客网 时间:2024/05/17 04:40
1)/res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" ><ImageSwitcher android:id="@+id/imageswitch" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:id="@+id/button" android:text="ImageSwitcher"android:layout_width="wrap_content" android:layout_height="wrap_content" /></LinearLayout>
2)com.sxt.ImageSwitcherActivity.java
package com.sxt;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.view.animation.AnimationUtils;import android.widget.Button;import android.widget.ImageSwitcher;import android.widget.ImageView;import android.widget.ViewSwitcher.ViewFactory;public class ImageSwitcherActivity extends Activity { /** Called when the activity is first created. */int position = 0;private Integer [] imageIds ={R.drawable.p1 , R.drawable.p2, R.drawable.p3,R.drawable.p4 , R.drawable.p5, R.drawable.p6,}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //final对象,引用不变。final基本类型,数据不变。 final ImageSwitcher imageSwitch = (ImageSwitcher)this.findViewById(R.id.imageswitch); Button button = (Button)this.findViewById(R.id.button); //显示视图,设置工厂类的makeView方法。 imageSwitch.setFactory(new ViewFactory() {@Overridepublic View makeView() {// TODO Auto-generated method stubreturn new ImageView(ImageSwitcherActivity.this);}}); imageSwitch.setImageResource(imageIds[position]); //设置切入动画 imageSwitch.setInAnimation(AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.slide_in_left)); //设置切出动画 imageSwitch.setOutAnimation(AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.slide_out_right)); button.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubif(position < imageIds.length-1 ){position++;}else{position = 0;}imageSwitch.setImageResource(imageIds[position]);}}); }}
3)如图
- android控件18 ImageSwitcher
- Android控件之ImageSwitcher
- Android 高级控件学习--ImageSwitcher
- (android控件)ImageSwitcher介绍和使用说明
- Android UI控件之ImageSwitcher(图片切换)
- Android 控件之ImageSwitcher图片切换器
- android 控件 切换图片(ImageSwitcher)(未完成)
- Android UI控件之ImageSwitcher(图片切换)
- android的ImageSwitcher控件及简单动画
- Android[初级教程] 第九章 Gallery控件和ImageSwitcher控件
- Android---被弃用的Gallery控件+ImageSwitcher控件基础
- Android ImageSwitcher
- Android ImageSwitcher
- android ImageSwitcher
- android ImageSwitcher
- Android 控件之Gallery和ImageSwitcher图片切换器
- Android UI控件详解-ImageSwitcher(图片切换器)
- Android应用开发控件——Gallery和ImageSwitcher
- .NET限制程序一次只能运行一个实例
- Canvas的save和restore
- Java编写好的全国省市名称
- 负载均衡(Load Balance)
- VC++ WM_TIMER 定时器使用方法
- android控件18 ImageSwitcher
- Java实验7 流
- GetPrivateProfileStruct大小限制
- M-Tree for Similarity Search
- 【C/C++】指针数组
- Android ApiDemos详解之App/Activity/Dialog(4)
- VS实用快捷键及技巧整理
- wxpython第一课基本开发步骤
- 第一部分 核心动画开篇---第一章 什么是核心动画