Search code examples
androidandroid-studioandroid-viewpager2

Android Viewpager2 and RecyclerView Item onClick listener


I have implemented Viewpager2 Image slider using the code idea mentioned in the following link.

I want handle clicks on the slider images. How to Open another activity if the specific slider item clicked.

Here is the link of code

https://androidapps-development-blogs.medium.com/android-modern-image-slider-using-viewpager-2-and-kenburnsview-android-studio-23a7b74317e8


Solution

  • On your adapter go to TravelLocationViewHolder. After this line

    textLocation = itemView.findViewById(R.id.textLocation);

    try to set a click listener on itemview

    itemView.setOnClickListener( v-> { System.out.println("THIS IS IT"); } );