0

In my android app I want to give simple copy paste option. User can copy text from text view by long clicking on it and I am successfully complete it, But not getting how can paste it to a edit text. I am trying long press on a edit text but paste option is not available.

I know I can get content from ClipBoardManager by below code -

ClipboardManager clipMan = (ClipboardManager)getSystemService(v.getContext().CLIPBOARD_SERVICE);
 myEdtTxt.setText(clipMan.getText());

but not getting how to get paste option.

Thanks in advance.

Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90
Guess
  • 238
  • 1
  • 2
  • 13
  • Isn't this already available with the `Context Action Bar` ? – PPartisan Jul 21 '15 at 09:52
  • Why don't you use a string to store the text from the TextView and add it to the EditText? – tobyUCT Jul 21 '15 at 09:59
  • I think you are not getting my question.i want to give paste option to user.when user long press on edit text there should an option for paste content from clipboard. – Guess Jul 21 '15 at 10:24

2 Answers2

0

Try setting android:cursorVisible="true" in your EditText's layout xml

Logic
  • 2,230
  • 2
  • 24
  • 41
0

Depending on your requirements, it may be simpler to use Android's in built Context Action Bar. This will allow you to copy/paste text reliably and with the least amount of effort.

If you want to copy text from a TextView, not an EditText, you will first need to make it selectable. For that you can either add the following xml attribute:

android:textIsSelectable = "true"

Or add the following programmatically:

textView.setTextIsSelectable(true);
PPartisan
  • 8,173
  • 4
  • 29
  • 48
  • as I mention in my question I am able to copy text,but don't know how to give paste option to user in edit text. – Guess Jul 21 '15 at 10:21
  • Just do a long press on any `EditText` field, and by default a `Contextual Action Menu` will appear and allow the paste option. Here's a screenshot I took a second ago: https://drive.google.com/file/d/0BygzWY4QsrwESmswZXd6S3dyQ2c/view?usp=sharing – PPartisan Jul 21 '15 at 10:26