public void onBindViewHolder(@NonNull final holderView holderView, final int position) {
holderView.insptext.setText(inspirationItemsList.get(position).getName());
holderView.copy.setImageResource(inspirationItemsList.get(position).getCopy());
holderView.share.setImageResource(inspirationItemsList.get(position).getShare());
holderView.copy.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Toast.makeText(v.getContext(), "Copied to clipboard" , Toast.LENGTH_SHORT ).show();
}
});
Asked
Active
Viewed 60 times
-3

AskNilesh
- 67,701
- 16
- 123
- 163

Willie Mwaniki
- 5
- 1
-
4What is your question?? – Mohammad Zarei Apr 17 '19 at 09:30
2 Answers
0
If you want to copy to clipboard programatically here is the reference link :
And this is how you implement it :
import android.content.ClipboardManager;
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("label", "Text to copy");
clipboard.setPrimaryClip(clip);
And here is the documentation for the ClipboardManager

coroutineDispatcher
- 7,718
- 6
- 30
- 58
-
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/22775916) – Samuel Philipp Apr 17 '19 at 10:30
-
2
-1
In order to copy something in your clipboard, use the code below:
ClipboardManager clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(label, text);
clipboard.setPrimaryClip(clip);

Mohammad Zarei
- 1,773
- 14
- 33