android_viewFlipper(一)
需要注意的地方已在代码中表明
package cn.com.sxp; import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ViewFlipper; public class ViewFlipperActivity extends Activity {
// 该例子显示,一个viewFlipper加载了三个线性布局,每个线性布局包含一个button,一个imageView。
// 这三个线性布局不是同时显示,是轮番显示,一个线性布局按照动画效果向左离去,另一个线性布局从右而来
private ViewFlipper viewFlipper = null;
Button btnOne = null, btnTwo = null, btnThree = null; /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); btnOne = (Button) findViewById(R.id.btnOne);
viewFlipper = (ViewFlipper) findViewById(R.id.vf);
btnOne.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// 在layout中定义的属性,也可以在代码中指定
// setInAnimation():
// Specifies the animation 动画 used to animate a View that enters the screen.
// Parameters
// context The application's environment.
// resourceID The resource id of the animation.
//
// Return the context of the single, global Application object of the current process. This
// generally should only be used if you need a Context whose lifecycle is separate from the
// current context, that is tied to the lifetime of the process rather than the current
// component.
// viewFlipper.setInAnimation(getApplicationContext(), R.anim.push_left_in); // setOutAnimation():
// Specifies the animation used to animate a View that exit the screen.
// viewFlipper.setOutAnimation(getApplicationContext(), R.anim.push_left_out); // setPersistentDrawingCache():
// Indicates what types of drawing caches should be kept in memory after they have been
// created.
// viewFlipper.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES); // setFlipInterval();
// How long to wait before flipping to the next view
// viewFlipper.setFlipInterval(1000);
// showNext()
// Manually shows the next child.
// viewFlipper.showNext();
// 调用下面的函数将会循环显示mViewFlipper内的所有View。
// mViewFlipper.startFlipping();
}
}); btnTwo = (Button) findViewById(R.id.btnTwo);
btnTwo.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
viewFlipper.showNext();
} }); btnThree = (Button) findViewById(R.id.btnThree);
btnThree.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
viewFlipper.showNext();
} }); }
}
运行效果如下;

点击按钮,即可看到左右换的图片。
android_viewFlipper(一)的更多相关文章
- Android_ViewFlipper
xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:t ...
- android 基本控件使用
http://tech.it168.com/a2012/0321/1327/000001327704.shtml Android_ListView_用代码控制ListView的位置 有三种方法 mli ...
随机推荐
- Win8Metro(C#)数字图像处理--2.4图像颜色聚类
原文:Win8Metro(C#)数字图像处理--2.4图像颜色聚类 [函数名称] 图像颜色聚类函数ClusterProcess(WriteableBitmap src,int value) [算 ...
- Advanced Installer,搜索注册表,根据注册表选择安装路径
原文:Advanced Installer,搜索注册表,根据注册表选择安装路径 又停了一段时间没有更新了,今天上博客,发现有位朋友就打包的时候需要搜索注册表(不同版本注册表路径不一致,需要搜索多次来确 ...
- 理解typedef(转)
// 从别人那转的,调整下格式便于阅读. 首先请看看下面这两句: typedef ]; typedef void (*p)(void); 如果你能一眼就看出它们的意思,那请不要再往下看了.如果你不太理 ...
- Visual studio调试Web发生未能正常启动IIS express
今天调试web时,不知道怎么搞的,昨天还好好的,结果今天怎么也没法调试了.VS里报的错误是进程号为**的未能正常启动,看了下调试时IIS压根就没启动起来,没关系,看看事件管理器里发生了什么 找到个最关 ...
- BI-学习之 新概念介绍
什么是统一维度模型 层次结构.级别.成员和度量值 什么是MDX MDX与SQL的区别 什么是数据仓库 什么是OLAP数据分析引擎 BI企业级解决方案 什么是统一维度模型 维度(dimension)是描 ...
- Qt浅谈之二十七进程间通信之QtDBus good
一.简介 DBus的出现,使得Linux进程间通信更加便捷,不仅可以和用户空间应用程序进行通信,而且还可以和内核的程序进行通信,DBus使得Linux变得更加智能,更加具有交互性. DB ...
- 检索 COM 类工厂中 CLSID 为 {{10020200-E260-11CF-AE68-00AA004A34D5}} 的组件时失败解决办法
检索 COM 类工厂中 CLSID 为 {10020200-E260-11CF-AE68-00AA004A34D5} 的组件时失败,解决方法如下: 第一步:首先将msvcr71.dll, SQLDM ...
- Spring Type Conversion(Spring类型转换源码探究)
1:概述 类型转换系统负责Spring框架中对象类型转换和格式化工作. ConversionService默认实现UML图如下所示: GenericConversionService(通用类型转换服务 ...
- 深入浅出Ajax
原文(我的GitHub):https://github.com/liangfengbo/frontend-ability/issues/1 学习大纲 理解Ajax的工作原理 Ajax核心-XMLHtt ...
- Tido 习题-二叉树-区间查询
题目描述 食堂有N个打饭窗口,现在正到了午饭时间,每个窗口都排了很多的学生,而且每个窗口排队的人数在不断的变化.现在问你第i个窗口到第j个窗口一共有多少人在排队? 输入 输入的第一行是一个整数T,表示 ...