0

I have a fragment containing a RecyclerView and an EditText. When the RecyclerView is refreshed using runOnUiThread(), the cursor from edit text is lost. How to retain cursor in EditText when runOnUiThread() is called, without chaging values in EditText.

  • Possible duplicate of [Set Focus on EditText](https://stackoverflow.com/questions/14327412/set-focus-on-edittext) – Rohit5k2 Jan 29 '18 at 12:05
  • 1
    I do not think that's a duplicate, because OP has `EditText` inside `RecyclerView`, which can be tedious to handle. – azizbekian Jan 29 '18 at 12:06
  • OP just has to get the instance of the EditText that needs focus. So with little bit of self work and this is a duplicate. – Rohit5k2 Jan 29 '18 at 12:11
  • i have tried focus but that does not solve my problem. Whenever the runOnUiThread() is called to refresh recyclerView the cursor from edit text is lost. –  Jan 29 '18 at 13:45

1 Answers1

0

Try call requestFocus() on EditText instance.

  • that works. I used requestFocus() inside runOnUiThread() and it works now. Thanks –  Jan 29 '18 at 13:50