Swipe detection for each row of listview

后端 未结 6 724
长情又很酷
长情又很酷 2021-02-18 16:32

I have a list of videos located in the sd-card. At this point, I just need help in creating gestures or swipe detection for each row in the list view. Thanks to this question at

6条回答
  •  天涯浪人
    2021-02-18 17:03

    Take a look into this answer and use pointToPosition method inside onFling Event

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        try {
            Toast.makeText( listAdapter.getItem( listView.pointToPosition(Math.round(e1.getX()), Math.round(e1.getY())).toString());
            return super.onFling();
        } catch( Exception e ) {
            // do nothing
        }
    }
    

提交回复
热议问题