문제

I have a class that extends Gallery called MyGallery and I have a set of bitmaps to show in a MyGallery widget. In order to swipe only one item per gesture, I had to override the onFling() so it won't call the super.onFling(). The problem is that in order to change item, I have to swipe more than 50% of the screen size and it's bothering me. I did a search but I didn't find any ways to change this minimum limit. Is there any way to do this?

도움이 되었습니까?

해결책

You can use the MotionEvent object to handle the minimum and maximum Swipe distances.
Calculate the swipe distance using the MotionEvent object i.e.., event.

@Override
public boolean onTouchEvent(MotionEvent event)
{
    // TODO Auto-generated method stub
    float rawX = 0.0f, dist;
    switch (event.getAction()) 
    {
    case MotionEvent.ACTION_DOWN:
        rawX = event.getX();
        break;
    case MotionEvent.ACTION_UP:
        dist = event.getX() - rawX;
        break;
    default:
        break;
    }
    return super.onTouchEvent(event);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top