0

I am using recyclerview. And there are two textview in recyclerview item. I am unable to add multiple text in clipboard. But I need both text. Here is my code.


      public NameViewHolder(View itemView) {
            super(itemView);
            name = itemView.findViewById(R.id.name);
            meaning = itemView.findViewById(R.id.meaning);
            copyText = itemView.findViewById(R.id.txtCopy);



        copyText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                clipboardManager = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
                clipData = ClipData.newPlainText("text",name.getText());
                clipboardManager.setPrimaryClip(clipData);
                
            }
        });

    }

Now I want to add both textview text into clipboard. Please help me. Thanks in advance.

Tahmid
  • 35
  • 4
  • 1
    You can try concatenating two strings. like `clipData = ClipData.newPlainText("text",name.getText() +"\n"+ meaning.getText()); ` – Mayur Gajra Mar 07 '21 at 12:48
  • @Mayur Gajra, Thanks for your advice. Its working after adding `+"\n"+ meaning.getText()` – Tahmid Mar 07 '21 at 14:52

0 Answers0