How to copy the text from ListView?For copying text i am usin clipboard manager.But,It's not working. here is my code :
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
String message = mMessagelist.get(arg2).getMessage_text().toString();
if (true) {
CLIPBOARD_TEXT = ((TextView) findViewById(R.id.message))
.getText().toString();
alert.showAlertDialog(MessagesActivity.this, "",
"Your text is copied to clipboard", false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("simple text",
CLIPBOARD_TEXT);
clipboard.setPrimaryClip(clip);
} else {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(CLIPBOARD_TEXT);
}
}
return true;
}
when user long click on item i am just showing a popup and copy the text but it's not working..Please help me.