Android:Synchronization of Images on fling and onclick also to show previous and next view same images

…衆ロ難τιáo~ 提交于 2019-12-31 03:00:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!