0

I have a multi-line TextView in Android which has a copy option on long press.

When the user presses on copy, this is the cody I execute:

ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("Answer", tv_answer.getText().toString().trim() + "");
clipboard.setPrimaryClip(clip);

My TextView holds text like - "this is a long text which spans all of three lines" and shows "this is a long ..." because I've set android:ellipsize="end".

The problem is, tv_answer.getText() will return the whole text that I'm setting to my TextView. I only need the text before the ellipses.

I need some guidance with using tv_answer.getLayout().getEllipsisCount() or tv_answer.getLayout().getEllipsisStart() or something similar to only get the text before the ellipses.

Mallika Khullar
  • 1,725
  • 3
  • 22
  • 37
  • Try standard method: To enable the standard copy/paste for TextView, U can choose one of the following: Change in layout file: add below property to your TextView. android:textIsSelectable="true" In your Java class write this line to set it programmatically. myTextView.setTextIsSelectable(true); – Myth Oct 25 '16 at 11:56
  • Hey, thanks for the suggestion but I need to show a custom dialog for copying as per the UI of my app, so it needs to be a by handling a longClick event. – Mallika Khullar Oct 25 '16 at 12:37

0 Answers0