I have this code below which is implemeting a touch listener for recyclerView. But when touching the View on Touch is not called.
What am i doing wrong?
public class MainActivity extends AppCompatActivity {
private RecyclerView recyclerView;
private GestureDetectorCompat detector;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
detector = new GestureDetectorCompat(this, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onFling (MotionEvent e1, MotionEvent e2,float velocityX,
float velocityY){
return false;
}
});
recyclerView.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v,MotionEvent event) {
return detector.onTouchEvent(event);
}
});
}
}