daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class MyAdapter(val friendList: List<FriendListData.Friend>) :
  2.     RecyclerView.Adapter<CountryAdapter.MyViewHolder>() {
  3.  
  4.     inner class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
  5.         var name: TextView = view.findViewById(R.id.text1)
  6.         var popText: TextView = view.findViewById(R.id.text2)
  7.     }
  8.  
  9.     override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
  10.         val friend = friendList[position]
  11.        
  12.         val status = if(friend.maritalStatus == "Married") {
  13.             "Sold out"
  14.         } else {
  15.             "Available"
  16.         }
  17.        
  18.         holder.name.text = friend.name
  19.         holder.popText.text = friend.email
  20.         holder.status.text = status
  21.     }
  22.  
  23.     override fun getItemCount(): Int {
  24.         return friendList.size
  25.     }
  26.  
  27.     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
  28.         val view = LayoutInflater.from(parent.context).inflate(R.layout.item_friendlist, parent, false)
  29.         return MyViewHolder(view)
  30.     }
  31. }
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