You can add event listeners to catch events like:
-
image click event
-
long image click event
-
page change event
You can add on image click listener using GalleryBuilder (recommended approach):
.onImageClickListener(new ScrollGalleryView.OnImageClickListener() {
@Override
public void onClick(int position) {
Toast.makeText(MainActivity.this, "image position = " + position, Toast.LENGTH_SHORT).show();
}
})
Or add event listener right to the ScrollGalleryView:
galleryView.addOnImageClickListener(new ScrollGalleryView.OnImageClickListener() {
@Override
public void onClick(int position) {
}
});
You should not add listeners directly to the ScrollGalleryView cause you can face with initialization bug. More details here.
Add long click listener with GalleryBuilder (recommended approach):
.onImageLongClickListener(new ScrollGalleryView.OnImageLongClickListener() {
@Override
public void onClick(int position) {
Toast.makeText(MainActivity.this, "image position = " + position, Toast.LENGTH_SHORT).show();
}
})
Or add it to the ScrollGalleryView:
galleryView.addOnImageLongClickListener(new ScrollGalleryView.OnImageLongClickListener() {
@Override
public void onClick(int position) {
}
});
For now library supports only adding this listener directly to the ScrollGalleryView:
galleryView.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});