The getSelectionStart(Textview) method returns incorrect value

Asked

Viewed 39 times

0

I need to recover a user-selected string in a Textview, but the method getSelectionStart returns the same value as getSelectionEnd.

Here is an example in the image below:

getSelectionStart

I performed the test on a Samsung Galaxy S7 Edge and an Asus and both showed the same behavior.

Does anyone know any other way to retrieve a selected string in a Textview?

EDIT:

Sample code:

TextView textView = (TextView) findViewById(R.id.text_view);
int selectionStart = textView.getSelectionStart(); // Retorna 10 (era pra retornar 4)
int selectionEnd = textView.getSelectionEnd(); // Retorna 10 (correto)

Thank you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.