sayyam / carouselview

A simple library to add carousel view in android app.
Apache License 2.0
1.15k stars 260 forks source link

How to make carouselview clickable? #45

Closed capella55 closed 7 years ago

capella55 commented 7 years ago

I'm going to move to next page, when carouselview is clicked. How can I implement this feature?

capella55 commented 7 years ago

Here is the solution.

CarouselViewPager pager = (CarouselViewPager) view.findViewById(R.id.containerViewPager); final GestureDetector tapGestureDetector = new GestureDetector(context, new TapGestureListener()); pager.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { tapGestureDetector.onTouchEvent(event); return false; } });

class TapGestureListener extends GestureDetector.SimpleOnGestureListener{ @Override public boolean onSingleTapConfirmed(MotionEvent e) { // Here you can do anything you want. return false; } }

leonardo2204 commented 7 years ago

I've dropped a PR with this feature, hope the author reviews and accept it !