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 ...
随机推荐
- HTML特殊编码转换
var encoded = ""'&<>¡¢£¤" + "¥¦§¨©ª«¬®" + "¯°±²³´µ¶·" ...
- linux的自动化操作相关使用方法汇总 专题
Crontab中的除号(slash)到底怎么用? crontab 是Linux中配置定时任务的工具,在各种配置中,我们经常会看到除号(Slash)的使用,那么这个除号到底标示什么意思,使用中有哪些需要 ...
- LINQ查询表达式---------select子句
LINQ查询表达式---------select子句 1.1常见的select子句查询 class Program { public class PerInfo { public int Id { g ...
- [机器学习]Bagging and Boosting
Bagging 和 Boosting 都是一种将几个弱分类器(可以理解为分类或者回归能力不好的分类器)按照一定规则组合在一起从而变成一个强分类器.但二者的组合方式有所区别. 一.Bagging Bag ...
- Linux基础命令杂记
今天又一次搞Linux生产环境搭建.这是种步骤很多,很繁琐而且又不得不做的事情.虽然做过很多次,但还是有很多步骤.命令不记得,每一次到处找资料很麻烦,于是将一些步骤记下,以便查找. 登录远程MySQL ...
- FreeCL
FreeCL 1.03(Free Control Library)是一个开源且免费的Windows控件库,它属于3D图形引擎FreeGE中的一部分,用户可以自由地用于个人或商业开发.FreeCL使用类 ...
- ORACLE(系统表student) 基本与深入学习
(一).首先我们先创建student表(系统有的可以跳过往下看)没有直接复制运行即可. create table student(sno varchar2(3) not null, --学号sname ...
- C++标准库(体系结构与内核分析)(侯捷第一讲)
一.C++标准库介绍 C++标准库:C++ Standard Library C++标准库与STL有什么关系: STL:Standard Template Library STL包含6大部件,基本占标 ...
- Angular2国际化
使用angular-cli初始化项目: ng new my-project 使用npm安装ngx-translate模块 npm install --save @ngx-translate/core ...
- AbstractQueuedSynchronizer(AQS)源码解析
关于AQS的源码解析,本来是没有打算特意写一篇文章来介绍的.不过在写本学期课程作业中,有一门写了关于AQS的,而且也画了一些相关的图,所以直接拿过来分享一下,如有错误欢迎指正. ...