AzisMM

InspirationListAdapter

Nov 8th, 2021
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.92 KB | None | 0 0
  1. class InspirationListAdapter(private val listInspiration: ArrayList<InspirationModel>) : RecyclerView.Adapter<InspirationListAdapter.ListViewHolder>() {
  2.  
  3.     inner class ListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
  4.         var imgPhoto: ImageView = itemView.findViewById(R.id.iv_item_photo)
  5.     }
  6.  
  7.     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListViewHolder {
  8.         val view: View = LayoutInflater.from(parent.context)
  9.             .inflate(R.layout.item_row_inspiration, parent, false)
  10.         return ListViewHolder(view)
  11.     }
  12.  
  13.     override fun getItemCount(): Int {
  14.         return listInspiration.size
  15.     }
  16.  
  17.     override fun onBindViewHolder(holder: ListViewHolder, position: Int) {
  18.         val inspiration = listInspiration[position]
  19.         Glide.with(holder.itemView.context)
  20.             .load(inspiration.inspirationImage)
  21.             .into(holder.imgPhoto)
  22.     }
  23. }
Add Comment
Please, Sign In to add comment