tomer mor tomer mor - 1 year ago 108
Android Question

viewflipper with different views

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: could I flip between them with viewFlipper?

with myFlipper.addView(myView) or should i use tag inside the viewFlipper layout? 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) {
flipper = (ViewFlipper) findViewById(;
myView1 temp1= new myView1 (this);

flipper.addView(myView1 , 1);

Answer Source
ViewFlipper flipper = (ViewFlipper) findViewById(;

//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

//Move between them

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download