viewflipper有不同的看法 [英] viewflipper with different views

查看:171
本文介绍了viewflipper有不同的看法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建立三个查看一圈,在每个视图两个按钮$ P $光伏和明年查看所有三个查看它们连接起来。 我有三个布局为每个视图,三CustomView的膨胀与相应的布局。 而且最重要的一项活动是举办ViewFlipper。

我的问题是:

1.how我可以在它们之间翻转与viewFlipper?
 与myFlipper.addView(MyView的),或者我应该使用标签viewFlipper布局里面?

2.how夸大我的看法与相关布局 我已经尝试 LayoutInflater吹气=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);         inflater.inflate(R.layout.t1,NULL);

我的行为看起来像这样

 公共类活动1扩展活动{
   私人ViewFlipper脚蹼;

   公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.view_fliper_layout);
     脚蹼=(ViewFlipper)findViewById(R.id.flipper);
     myView1 temp1中=新myView1(本);

     flipper.addView(myView1,1);
     flipper.setDisplayedChild(1);
     }
 }
 

解决方案

  ViewFlipper鳍状肢=(ViewFlipper)findViewById(R.id.flipper);

//充气的意见
LayoutInflater充气=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
查看V1 = inflater.inflate(R.layout.t1,NULL);
查看V2 = inflater.inflate(R.layout.t2,NULL);
查看V3 = inflater.inflate(R.layout.t3,NULL);

//添加欣赏到脚蹼
viewFlipper.addView(V1);
viewFlipper.addView(V2);
viewFlipper.addView(第三版);

它们之间//将
flipper.showNext();
flipper.show previous();
 

http://developer.android.com/reference/android/widget/ViewAnimator.html#showNext()

I want to build circle of three View,On each view two buttons to prev and next View all the three View connected by them. I have three layout for each View, and three CustomView that inflate accordingly with the layout. and above all one Activity that hold ViewFlipper.

my questions is:

1.how could I flip between them with viewFlipper?
with myFlipper.addView(myView) or should i use tag inside the viewFlipper layout?

2.how to inflate my view with the relevant Layout I already try LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.t1, null);

my activity looks like this

public class Activity1 extends Activity {
   private ViewFlipper flipper;

   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_fliper_layout);
     flipper = (ViewFlipper) findViewById(R.id.flipper);
     myView1 temp1= new myView1 (this); 

     flipper.addView(myView1 , 1);     
     flipper.setDisplayedChild(1);
     }
 }

解决方案

ViewFlipper flipper = (ViewFlipper) findViewById(R.id.flipper);

//Inflate the Views
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v1 = inflater.inflate(R.layout.t1, null);
View v2 = inflater.inflate(R.layout.t2, null);
View v3 = inflater.inflate(R.layout.t3, null);

//Add the views to the flipper
viewFlipper.addView(v1);
viewFlipper.addView(v2);
viewFlipper.addView(v3);

//Move between them
flipper.showNext();
flipper.showPrevious();

http://developer.android.com/reference/android/widget/ViewAnimator.html#showNext()

这篇关于viewflipper有不同的看法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆