简体   繁体   中英

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. 在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM