Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
While working with the recycler view , we often feel the need to implement a listener on the whole recycler view so that if any one item is selected we may trigger the action as per our need.
One way is to perform the same action on click of every element of the itemView in Recycler view’s onBindViewHolder function. But then that redundant, repetitive and also not at all good approach.
Another is to add the addOnItemTouchListener to your recycler view. But problem with this is that you need to override the three methods viz :
and implementing this is not very easy, as two of these take motionevents as input and you need to know how to handle this or you can convert these to something that most of the listeners have(like onClick) and use them as per your need .
So lets begin the coding :
CODE : for the class
Now with this being done , all you need to do to your recycler view is to set an instance of this class. take a look at how to do the same.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
All communication is done through a ticket system. I appreciate the regular almost daily updates of what is being worked on, and communicating changes or updates is easy through this system. Mobikul's response timeframe is quick.
Josh Arnold
Owner, Shop ATV Escape
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.