Reputation: 195
Having some difficulty with a viewflipper atm. If I set the viewflipper to the last child view at the start it works and goes to the last view. If I set it to the first view and navigate through the views, it reaches a black screen before the final view.
flip=(ViewFlipper)findViewById(R.id.flipper);
flip.setInAnimation(this,android.R.anim.fade_in);
flip.setOutAnimation(this, android.R.anim.fade_out);
curdate.setText(currentDate);
next.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
flip.setDisplayedChild(1);
}
});
next1.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
flip.setDisplayedChild(2);
}
});
next2.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
flip.setDisplayedChild(3);
}
});
previous.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
flip.setDisplayedChild(0);
}
});
previous1.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
flip.setDisplayedChild(1);
}
});
previous2.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
flip.setDisplayedChild(2);
}
});
As above, the last view should be 3, and if I put flip.setDisplayedCHild(3) before the onClickListeners, it goes to the end and works, but going through normally, it just reaches a black screen.
My xml code is a bit too long to show, but it consists of a ScrollView,a LinearLayout,then a ViewFlipper,and the ViewFlipper's views are all TableLayouts.
Appreciate any help
Upvotes: 2
Views: 579
Reputation: 1858
I know that this question is old but maybe it will help someone.
It seems that ViewFlipper
adds some views when it is initialized.
You should call removeAllViews()
before adding your own views.
Upvotes: 1