I wanted to copy and paste a string into a ListView, the function I'm using is just copying follows the function:
// Função Copiar
private void copiarTarefa(Context context, String text) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(text);
} else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("Texto copiado: ", text);
clipboard.setPrimaryClip(clip);
}
Toast.makeText(context, "Texto copiado", Toast.LENGTH_LONG).show();
}
When I call the function like this:
// Copiar Nota
listaTarefas.setLongClickable(true);
listaTarefas.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
copiarTarefa(getApplicationContext(), textoTarefa.getText().toString());
return true;
}
});
It just copies and does not glue, just does literally copy .. where is the error, because I am not able to recover the note to be able to paste