Arkaprabha Mahata
Arkaprabha Mahata

Reputation: 65

Edittext looses focus when recyclerview is refreshed

So I have a list in which there are edit text and when I change value it should refresh the list t show updated value. But when list is refreshed the edit text looses focus and the keyboard closes.enter image description here

Upvotes: 1

Views: 210

Answers (1)

Avinash Tilekar
Avinash Tilekar

Reputation: 36

This is correct behaviour of recyclerview.

Options 1 in your recyclerview's model have some boolean value like hasFocus and set focus bases of value. (change value on onFocusChange of Edit text)

Options 2 if you want to keep focus in edit text in same position after refresh in that case you must keep index value of recyclerview in some variable before call refresh (where edit text has focus) and after refresh onBind you can set focus again from last recyclerview's position variable

Upvotes: 2

Related Questions