0

I have a listview and I set an onClickListener and an onTouchListener. The click listener for when they click on an item, I had just this and everything thing worked fine. But, when I added the touch listener to watch for left and right swipes, it won't let me scroll anymore.

listview.setOnTouchListener(new OnTouchListener(){
        public boolean onTouch(View v, MotionEvent event){
    switch (event.getAction()){
    case MotionEvent.ACTION_DOWN:
    historicX = event.getX();
    historicY = event.getY();
    break;

    case MotionEvent.ACTION_UP:
        if(event.getX() - historicX < -DELTA){
        slidingLeft(event.getX(),event.getY());
        return true;
        }
        else if(event.getX() - historicX > DELTA){
            slidingRight(event.getX(), event.getY());
        return true;
        }
            break;
        default: return true;
    }
    return false;
}
});

How can I have to able to scroll through the listview again. Is there another listener I could add to do this, or could I modify the onTouchListener to watch for scrolls too?

TheKingDoof
  • 45
  • 1
  • 6

1 Answers1

1

You should use GestureDetector . You can use example from here, it is very clear. https://stackoverflow.com/a/12938787/1374065

Community
  • 1
  • 1
vanste25
  • 1,754
  • 14
  • 39
  • 1
    Sweet thanks that could work. Now I just got to figure what to put in the swipe functions to make it scroll. Thanks again. – TheKingDoof Apr 14 '14 at 01:38