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 ...
随机推荐
- Apache Cordova for ios环境配置
原文:Apache Cordova for ios环境配置 1.安装针对iOS的工具 https://technet.microsoft.com/ZH-cn/library/dn757054.aspx ...
- 用蓝牙连接debian和诺基亚手机
本方法已经用debian 4.0.诺基亚9300和一个hl-united牌子的USB蓝牙适配器测试过了,效果很好. 1.安装必要的软件包: #apt-get install ...
- 使用Newtonsoft.Json输出JSON
安装: Install-Package Newtonsoft.Json 代码: //序列化DataTable DataTable dt = new DataTable(); dt.Columns.Ad ...
- storm和kafka的wordCount
这个是在window环境下面安装的kafka 下载pom依赖 <dependency> <groupId>org.apache.storm</groupId> &l ...
- GzipStream的简单使用压缩和解压
压缩和解压都需要用到三个流实例,分别是文件读取流.文件写入流.压缩流. 读取流和写入流有多种形式,压缩流就一种GzipStream. 不同的是对于压缩,是需要用文件写入流作为创建压缩流实例的参数, 压 ...
- =WM_VSCROLL(消息反射) 和 WM_VSCROLL(消息响应)的区别(控件拥有者自己不处这个理消息,而是反射给控件对象本身来处理这个消息)
=WM_VSCROLL(消息反射) 和 WM_VSCROLL(消息响应)的区别 所谓消息反射就是控件拥有者自己不处这个理消息,而是反射给控件对象本身来处理这个消息 1.“=WM_VSCROLL”是消息 ...
- easyui tree后台传json处理问题
一.tree json格式 [ { "id": 1, "text": "权限管理", "iconCls": " ...
- acl_cpp 的编译与使用
注:因为现在 acl_cpp 已经合并进 acl 项目中,本文仅是介绍了老版本的 acl_cpp 的编译过程,新版本的介绍及编译请参考:acl 框架库简介. acl_cpp 是基于 acl 为基础开发 ...
- 核心思想:想清楚自己创业的目的(如果你没有自信提供一种更好的产品或服务,那就别做了,比如IM 电商 搜索)
这个时代对于学 IT 的人来说是幸运的.一个普通的程序员可以相对轻易地找到工作,可以轻易拿到比其他行业高得多的工资,甚至自己创建世界级的企业亦非空想.马云.马化腾等企业家的成功,似乎时刻提醒人们:即便 ...
- Spring Boot:集成Druid数据源
综合概述 数据库连接池负责分配.管理和释放数据库连接,它允许应用程序重复使用一个现有的数据库连接,而不是再重新建立一个:释放空闲时间超过最大空闲时间的数据库连接来避免因为没有释放数据库连接而引起的数据 ...