简体   繁体   中英

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

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"); } );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM