Search code examples
androidstringscrollandroid-edittexthorizontalscrollview

How to scroll to some char in EditText


I have a HorizontalScrollView with EditText inside.
EditText has text (for example):
"testing string testing string X testing string testing string Y testing string testing string test Z".
And i programmatically replace X with some string, then i replace Y with next some string, etc.

How do i scoll to place, where i replace text:
first: to X
second: to Y?

i try addTextChangedListener() to myEditText and on beforeTextChanged, afterTextChanged get start, end always return 0 (becouse i replace programmatically, dont it?).

Any suggestion?


Solution

  • My app is calculator and string "testing string testing string X testing string testing string Y testing string testing string test Z" is formula.
    And i can wrote every variable position in formula when user create one. So i have all of variables position and can scroll to another one)