How to copy the text present in a particular text view to clipboard when a button is pressed?
Asked
Active
Viewed 65 times
1 Answers
0
try below code on button click
String stringcopy = textView.getText().toString();
int startIndex = textView.getSelectionStart();
int endIndex = textView.getSelectionEnd();
stringcopy = stringcopy.subString(startIndex, endIndex);
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.setText(stringcopy);

Munir
- 2,548
- 1
- 11
- 20