Android Copy Text to Clipboard from TextView
by Sasikumar[ Edit ] 2014-03-20 22:41:01
Copy Text to Clipboard from TextView in Android:
TextView mytextview = (TextView)findViewById(R.id.textview);
final String copytext = mytextview.getText().toString();
mytextview.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
ClipboardManager myclipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData dataclip = ClipData.newPlainText("label", copytext);
myclipboard.setPrimaryClip(dataclip);
}
});