安卓:同步上一扔图像和的onclick也表现出previous和接下来的看法相同的图像图像、上一、表现出、接下来

2023-09-09 21:11:42 作者:十年戒马心孤单

我使用的是视图鳍翻转约20图像和翻转上刷卡,并在我的活动底部我有两个按钮,手动切换左图像或right.These两个是工作,但我不能够表现出相同的图:

有关,例如: 如果我从IMAGE2刷卡的Image3和明年我单击显示下一步按钮,然后它切换到阵列中的第一幅图像,但我要到第三image4.I知道它展示了他们该做的,但没有任何逻辑来解决特点这issue.Any帮助将是非常美联社preciable。

onfling方式:

 公共布尔onFling(MotionEvent EVENT1,MotionEvent EVENT2,浮velocityX,浮velocityY){
    如果(isDragMode)
        返回false;
    最终浮动ev1x = event1.getX();
    最终浮动ev1y = event1.getY();
    最终浮动ev2x = event2.getX();
    最终浮动ev2y = event2.getY();
    最终浮动xdiff = Math.abs(ev1x  -  ev2x);
    最终浮动ydiff = Math.abs(ev1y  -  ev2y);
    最终浮动xvelocity = Math.abs(velocityX);
    最终浮动yvelocity = Math.abs(velocityY);
    如果(xvelocity> this.SWIPE_MIN_VELOCITY和放大器;&安培; xdiff> this.SWIPE_MIN_DISTANCE){
        //vf1.removeAllViewsInLayout();
        vf1.removeViewInLayout(IM);
        i1.setVisibility(View.VISIBLE);
        如果(ev1x> ev2x)//向右滑动{
        ++ currentview;
        如果(currentview> =则为a.length){
            currentview =则为a.length  -  1;
            }
        vf.setInAnimation(animleftin);
        vf.setOutAnimation(animleftout);
        }其他{
         - 目前来看;
        如果(currentview℃,){
            currentview = 0;
        }
        vf.setInAnimation(animrightin);
        vf.setOutAnimation(animrightout);
        }
        vf.scrollTo(0,0);
        vf.setDisplayedChild(currentview);
    }
    返回false;
}
 

onclick事件:

  ImageView的RIT =(ImageView的)findViewById(R.id.imageView6);
rit.setOnClickListener(新OnClickListener(){
    公共无效的onClick(查看为arg0){
        // TODO自动生成方法存根
        vf.showNext();
    }

});
 
谈谈ios和安卓智能手机系统之间的一些区别

解决方案

看看这篇文章:的使用RealViewSwitcher到的意见,如主屏幕并的切换

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();
    }

});

解决方案

Check out this article: Use RealViewSwitcher to switch between views like the home screen does