Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save manavtamboli/ac3301090634d85517acf68b9a6743d3 to your computer and use it in GitHub Desktop.

Select an option

Save manavtamboli/ac3301090634d85517acf68b9a6743d3 to your computer and use it in GitHub Desktop.
// Added Parameter for the Layout Resource to inflate
class AdapterX<T>(
@LayoutRes private val layoutResId : Int,
diff : DiffUtil.ItemCallback<T>
) : ListAdapter<T, AdapterX.ViewHolder>(diff){
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(layoutResId, parent, false)
return ViewHolder(view)
}
class ViewHolder(view : View) : RecyclerView.ViewHolder(view)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment