Skip to content

Instantly share code, notes, and snippets.

Avatar

Addepalli Sri Rama Chandra Kashyap kashyapasrc

  • Machilipatnam, India
View GitHub Profile
@arcadefire
arcadefire / RecyclerViewExtension.kt
Last active Nov 14, 2021
Add addOnItemClickListener easily to a RecyclerView using Kotlin
View RecyclerViewExtension.kt
import android.support.v7.widget.RecyclerView
import android.view.View
interface OnItemClickListener {
fun onItemClicked(position: Int, view: View)
}
fun RecyclerView.addOnItemClickListener(onClickListener: OnItemClickListener) {
this.addOnChildAttachStateChangeListener(object: RecyclerView.OnChildAttachStateChangeListener {
override fun onChildViewDetachedFromWindow(view: View?) {