I have a EditText
- ed1
. I want to copy the contents of ed1
to clipboard
, concat
it with Hello World
and paste it to another EditText
- ed2
on the tap of a button
. But, I am getting some additional data along with the contents on ed1
.
final EditText ed1 = (EditText) findViewById(R.id.editText1);
final EditText ed2 = (EditText) findViewById(R.id.editText2);
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
String add = "Hello World";
ClipData clip = ClipData.newPlainText("", ed1.getText().toString().concat(" "+add));
clipboard.setPrimaryClip(clip);
ed2.setText(clip.toString());
}
});