Вопрос

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