daily pastebin goal
3%
SHARE
TWEET

adapter

a guest Sep 22nd, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ClubAdapter (private val context: Context, private val items: List<ItemClub>, private val listener: (ItemClub) -> Unit)
  2.     : RecyclerView.Adapter<ClubAdapter.ViewHolder>() {
  3.  
  4.     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
  5.             ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_club, parent, false))
  6.  
  7.     override fun onBindViewHolder(holder: ViewHolder, position: Int) {
  8.         holder.bindItem(items[position], listener)
  9.     }
  10.  
  11.     override fun getItemCount(): Int = items.size
  12.  
  13.     class ViewHolder (view : View) : RecyclerView.ViewHolder(view){
  14.  
  15.         fun bindItem(items: ItemClub, listener: (ItemClub) -> Unit) {
  16.             itemView.namatim.text = items.name
  17.             Glide.with(itemView.context).load(items.image).into(itemView.gambartim)
  18.             itemView.setOnClickListener {
  19.                 listener(items)
  20.             }
  21.         }
  22.     }
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top