title: How to get the variable value from adapter to activities in android kotlin recyclerview?
body: <p>I'm creating a chat app in android using kotlin and wanted to create a group item based on registered users.</p>
  
  <p>Currently I'm facing a problem on finding a way to pass the variable from the adapter going back to activities because i want to have a floating check button and display what are the selected users from that adapter. </p>
  
  <p>I browse the web but haven't found an ideal write-up about adaptes to activites.</p>
  
  <p>Please point me to some solutions/helpful articles about this. Or if this question is duplicated and answered successfully.</p>
  
  <p>Thanks</p>
  
  <p>AddUserGroupAdapter.kt</p>
  
  <p>....</p>
  
  <pre><code>override fun populateViewHolder(viewHolder: AddUsersGroupAdapter.ViewHolder?, user : Users?, position: Int) {
          var userId = getRef(position).key
  
          viewHolder!!.bindView(user!!,context)
  
  
          viewHolder.itemView.setOnClickListener {
              if(viewHolder.userSelected!!){
                  viewHolder.userSelected = false
                  //viewHolder!!.bindView(user!!,context)
                  viewHolder.userCheck!!.visibility = View.GONE
  
              }else{
                  viewHolder.userSelected = true
                  viewHolder.userCheck!!.visibility = View.VISIBLE
              }
  
              //TODO : I want to collect the Id's into list and 
              // will access to the activity(AddUserGroupActivity)
              //Toast.makeText(context,userId,Toast.LENGTH_LONG).show()
  
          }
  
  
      }
  </code></pre>
  
  <p>AddUserGroupActivity.kt</p>
  
  <p>...</p>
  
  <pre><code>class AddUsersGroupActivity : AppCompatActivity() {
      var mUserDatabase : DatabaseReference? = null
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_add_users_group)
  
          supportActionBar!!.setTitle("Add Users in Group")
          supportActionBar!!.setDisplayHomeAsUpEnabled(true)
  
  
  
          var lineaLayoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
  
          mUserDatabase = FirebaseDatabase.getInstance().reference
                  .child("Users")
  
          rvAddUsersGroup.setHasFixedSize(true)
  
          rvAddUsersGroup.layoutManager = lineaLayoutManager
          rvAddUsersGroup.adapter = AddUsersGroupAdapter(mUserDatabase!!, this)
  
          //TODO : This is where I wanted to have a floating action button onClickListener
          //that will access the variable from adapter and display to toast.
      }
  }
  </code></pre>