I want to enable standard copy paste for a TextView (the same as for EditText). How can I do it?
I tried using a non-editable EditText but it didn\'t work well (some
if someone wants to go the extra mile and do the select and copy to the clipboard with one click :
phone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("PhoneNumber", phone.getText());
clipboard.setPrimaryClip(clip);
}
});
phone is the TextView and phone.Text is the Text that will be copied to the clipboard.