Android Copy Text to Clipboard from TextView

by Sasikumar 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);
}
});
1118
like
0
dislike
0
mail
flag

You must LOGIN to add comments