• 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();
    			}
    
    		});
    
    	}
    }
    

      运行效果如下;

    点击按钮,即可看到左右换的图片。

  • 相关阅读:
    查看CLOUD系统级IIS日志
    采购订单设置采购部门为缺省值
    单据头数据复制到单据体
    CLOUD设置过滤方案不共享
    BZOJ 4773: 负环 倍增Floyd
    LOJ #539. 「LibreOJ NOIP Round #1」旅游路线 倍增floyd + 思维
    BZOJ 4821: [Sdoi2017]相关分析 线段树 + 卡精
    一些常用公式/技巧
    BZOJ 4517: [Sdoi2016]排列计数 错排 + 组合
    BZOJ 3162: 独钓寒江雪 树的同构 + 组合 + 计数
  • 原文地址:https://www.cnblogs.com/itblog/p/2322843.html
Copyright © 2020-2023  润新知