ViewPager that listens to clicks

64 Views Asked by At

I need a ViewPager that enables to user to swipe images. But on a click on the images, a new activity has to start with another, bigger viewpager that contains the same images.

How can i implement a click listener while still keeping the swipe on the viewpager?

1

There are 1 best solutions below

0
On BEST ANSWER

It should be pretty straight-forward, and has nothing to do with your ViewPager. Just add onClickListener to your ImageView:

ImageView.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        // start new activity here
        }
    }
});

or add the onClick in XML:

<ImageView
    ...
    android:onClick="startTheOtherActivity" />