0

I would like to have the possibility to mark and copy text in a TextView.

I want to overwrite onLongClick method. It should be working like in android browser. Just click, mark text and press copy. Is there a solution who works in most of android versions? enter image description here

John Smithv1
  • 673
  • 5
  • 14
  • 33
  • http://stackoverflow.com/questions/22832123/get-selected-text-from-textview , maybe this is what you seek? – mariuss Oct 05 '15 at 11:57

2 Answers2

0

You can try this in your TextView:

android:textIsSelectable="true" 

Note: Available from API level 11

breogangf
  • 36
  • 4
  • When I set android:textIsSelectable="true" I can select text yes. But It is not possible to copy the selected text. There is a button who copies the whole text and not only the selected one – John Smithv1 Oct 05 '15 at 12:16
  • This really depends on the device you are testing on...For example I tested this feature on a pure Android device (Nexus 5) and you can copy the selected text or the whole text. – breogangf Oct 05 '15 at 12:25
0

Does this work for you?

textView.setOnItemLongClickListener(new OnItemLongClickListener() { 

        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                int pos, long id) {

            Log.d(TAG, "long clicked");

            return true; 
        } 
    }); 
Razvan N
  • 554
  • 3
  • 9
  • 29