I want to highlight selected text in android textview.Can anyone tell me the possibility to get the start and end index of the selected text in android textview.
I use the following TextView for selecting a text.
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textIsSelectable="true"
android:bufferType="spannable"
/>
To highlight specifix string I use following code.How can I get start and end index of selected text.
SpannableString str = new SpannableString("Highlighted. Not highlighted.");
str.setSpan(new BackgroundColorSpan(Color.YELLOW), 0, 11, 0);
textView.setText(str);