在刷卡图像android期间找不到这样的方法

时间:2013-12-08 04:42:51

标签: android image swipe

我创建了滑动图像功能。它在nexus和小屏幕手机上运行良好。但是当我在7'标签或10'屏幕上运行时,它会抛出nosuchmethod错误(event.getAxisValue):下面是代码

public boolean onTouchEvent(MotionEvent event) {    
 float endXValue = 0;

 //ERROR is THROWING ON THIS LINE
 float x1 = event.getAxisValue(MotionEvent.AXIS_X);
 int action = MotionEventCompat.getActionMasked(event);

 switch (action) {
     case (MotionEvent.ACTION_DOWN):
         startXValue = event.getAxisValue(MotionEvent.AXIS_X);
         return true;

     case (MotionEvent.ACTION_UP):
         endXValue = event.getAxisValue(MotionEvent.AXIS_X);
         if (endXValue > startXValue) {
             if (endXValue - startXValue > 100) {
                 System.out.println("Left-Right");
                 count--;
                 int imageId = getImageViewId("prev");
                 imageView.setImageResource(imageId);

             }
         }else {
             if (startXValue -endXValue> 100) {
                 System.out.println("Right-Left");
                 int imageId = getImageViewId("next");
                 imageView.setImageResource(imageId);
                 count++;
            }
         }
         return true;
       default:
         return super.onTouchEvent(event);
  }

}

我正在使用API​​19

0 个答案:

没有答案