Reputation: 716
I want to implement a search. But unfortunately edit text must be in recycler view. I have multiple types of items. When user enters a letter I refresh whole adapter, searching is done locally. That means that keyboard disappears and edit text is losing focus, because of this constant updating. I managed to fix it showing keyboard and focus an edit manually while binding.
if (item.inEditableMode) {
edit_text.requestFocus()
showKeyboard(edit_text)
}
But edit text works not that good as I expect. A problem can be seen when user types fast or wants to clear input. Thanks for help.
Upvotes: 0
Views: 890
Reputation: 19243
"unfortunately edit text must be in recycler view" - I bet it do NOT have to be a part of RecyclerView
not part of Adapter
list item View
. better inspect your layout architecture instead of posted workarounds with hiding-showing (blinking) keyboard
besides that even when it must be then don't notify whole Adapter
with notifyDataSetChanged()
, instead use notifyItemChanged(...)
- notify range of of your items, but not list item with EditText
- it won't be redrawn, so keyboard should stay visible and focus kept on that field. still this isn't good approach, your EditText
should be separated from RecyclerView
almost for shure
Upvotes: 1