I got a RecyclerView
with multiple EditText
-fields. When I try to edit one of the EditText
-fields and click enter on the virtual keyboard, the focus shifts down to the next EditText
-field, something I don't want to happen. I want to submit the changes I made in the first EditText
-field and then close the keyboard. I managed to turn off this focus-shifting by adding the following to my .xml file:
android:focusable="true"
android:focusableInTouchMode="true"
But the problem still persists, now the changes just never get submitted as my listener never gets called. If I remove all items except from one in my RecyclerView
everything works like I want. How can I make that happen with more items in myRecyclerView
too?
My bind
function inside my UserCardItem.kt
file;
override fun bind(viewHolder: ViewHolder, position: Int) {
...
viewHolder.itemView.creditcard_nickname.setOnEditorActionListener{ _, actionId, _ ->
if(actionId == EditorInfo.IME_ACTION_DONE){
saveNickname(viewHolder)
true
} else {
false
}
}
private fun saveNickname(viewHolder : ViewHolder){
val nickname = viewHolder.itemView.creditcard_nickname.text.toString()
userCreditcard.nickname = nickname
UserCardStore().updateNickname(userCreditcard)
}