I am using a view flipper to flip around 20 images and flipping on swipe and on the bottom of my activity i have two button for manually switching the images left or right.These two are working but i am not able to show same image:
for eg: if i swipe from image2 to image3 and next i click show next button then its switching to first image in array but i want to go to third image4.I know its showing the characteristics what they suppose to do but do not have any logic to solve this issue.Any help would be really appreciable.
onfling method:
public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX,float velocityY){
if(isDragMode)
return false;
final float ev1x = event1.getX();
final float ev1y = event1.getY();
final float ev2x = event2.getX();
final float ev2y = event2.getY();
final float xdiff = Math.abs(ev1x - ev2x);
final float ydiff = Math.abs(ev1y - ev2y);
final float xvelocity = Math.abs(velocityX);
final float yvelocity = Math.abs(velocityY);
if(xvelocity > this.SWIPE_MIN_VELOCITY && xdiff > this.SWIPE_MIN_DISTANCE){
//vf1.removeAllViewsInLayout();
vf1.removeViewInLayout(im);
i1.setVisibility(View.VISIBLE);
if(ev1x > ev2x) //Swipe Right {
++currentview;
if(currentview >= a.length){
currentview = a.length - 1;
}
vf.setInAnimation(animleftin);
vf.setOutAnimation(animleftout);
}else{
--currentview;
if(currentview < 0){
currentview = 0;
}
vf.setInAnimation(animrightin);
vf.setOutAnimation(animrightout);
}
vf.scrollTo(0,0);
vf.setDisplayedChild(currentview);
}
return false;
}
Onclick event :
ImageView rit=(ImageView)findViewById(R.id.imageView6);
rit.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
// TODO Auto-generated method stub
vf.showNext();
}
});
来源:https://stackoverflow.com/questions/9276234/androidsynchronization-of-images-on-fling-and-onclick-also-to-show-previous-and