Hey I'm trying to copy text from recyclerview items into the clipboard its works when I try to do this inside an activity but when I try the code inside the viewholder i get Unresolved reference: CLIPBOARD_SERVICE erorr here is the code:
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
val currentitem = userList[position]
holder.username.text = currentitem.name
holder.app.text = currentitem.app
holder.password.text = currentitem.password
holder.copy.setOnClickListener(){
val clipboardManager = getSystemService(holder.itemView.context.CLIPBOARD_SERVICE) as ClipboardManager
val clipData = ClipData.newPlainText("text", currentitem.password)
clipboardManager.setPrimaryClip(clipData)
Toast.makeText(holder.itemView.context, "Text copied to clipboard", Toast.LENGTH_LONG).show()
}