Android - text selection - select a piece of text

How can I make TextView available in API <= 11? I searched a lot and found that I can use Editext as a TextView, but in any case it does not look good, and I need to send the selected part of the text to a new activity. Can someone help me?

An example of what I'm looking for is Onlongclick clicked in an OperaMini app. After a long click, it opens the cursor for the user who selects the part of the text that he needs, and ContextMenu for the selected part.

Thank x.

enter image description here

I need to do something like this. Printing, when longclinck, make displays a text selector (blue print hints) and shows the selected part.

+4
source share
1 answer

You either make it available in xml

android:textIsSelectable="true" 

or make your text click available by assigning it an Onclicklistener

  TextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText(TextView.getText()); } }); 
+13
source

Source: https://habr.com/ru/post/1498794/


All Articles