I think Amin NAIRI is correct here - setSelectionRange expects 2 parameters and you're only giving one.
This is hinted at in the name of the function: setSelectionRANGE
A selection is a highlight that has a length based on a beginning and an end. Even if the length is only 1 character. A length of 0 - where the end is not specified - is no highlight at all.
You could think of those indexes as existing between letters. So, to highlight one character at index i, you would draw a highlight from i (right before the character) to i+1 (right after the character).
In your code, you are specifying the beginning, but you are not specifying the end. If you update it to be paragraph.setSelectionRange(indexOfFirst, indexOfFirst+1), you might see some success.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi AndyBullet,
I think Amin NAIRI is correct here -
setSelectionRange
expects 2 parameters and you're only giving one.This is hinted at in the name of the function: setSelectionRANGE
A selection is a highlight that has a length based on a beginning and an end. Even if the length is only 1 character. A length of 0 - where the end is not specified - is no highlight at all.
You could think of those indexes as existing between letters. So, to highlight one character at index
i
, you would draw a highlight fromi
(right before the character) toi+1
(right after the character).In your code, you are specifying the beginning, but you are not specifying the end. If you update it to be
paragraph.setSelectionRange(indexOfFirst, indexOfFirst+1)
, you might see some success.