安卓:同步上一扔图像和的onclick也表现出previous和接下来的看法相同的图像 [英] Android:Synchronization of Images on fling and onclick also to show previous and next view same images

查看:120
本文介绍了安卓:同步上一扔图像和的onclick也表现出previous和接下来的看法相同的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是视图鳍翻转约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();
    }

});
 

解决方案

看看这篇文章:的使用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

这篇关于安卓:同步上一扔图像和的onclick也表现出previous和接下来的看法相同的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆