-2

I have one TextView, I want to get the text what user clicked by long press in TextView.

TextView is already selectable.

Suppose there is the line "This is my book" in TextView. If user click(select) on "book", I want to get that word on long press or onclick.

can somebody please help?

samirprogrammer
  • 342
  • 4
  • 18
  • What do you mean by selected text ? If you are looking for long press Context menu then just add `android:textIsSelectable=true` in layout xml under `TextView`. – ADM Jan 26 '19 at 14:59
  • textview is already selectable. Suppose there is line "This is my book" in textview . If user click(select) on "book" , i want to get that word on long press. – samirprogrammer Jan 26 '19 at 15:02
  • idk if it works but look at third answer in https://stackoverflow.com/questions/18653428/select-a-part-of-textview-text – Amas Jan 26 '19 at 15:16

1 Answers1

0

Inside your Text View tag place

android:textIsSelectable=true

you can also change the selected text highlighted color.

DEXTOR_ANTONY
  • 300
  • 1
  • 12