Android RecyclerView : notifyDataSetChanged() IllegalStateException

前端 未结 22 1842
天涯浪人
天涯浪人 2020-11-28 02:57

I\'m trying to update the items of a recycleview using notifyDataSetChanged().

This is my onBindViewHolder() method in the recycleview adapter.

@Over         


        
22条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 03:48

    For me problem occurred when I exited from EditText by Done, Back, or outside input touch. This causes to update model with input text, then refresh recycler view via live data observing.

    The Problem was that cursor/focus remain in EditText.

    When I have deleted focus by using:

    editText.clearFocus() 
    

    Notify data changed method of recycler view did stop throwing this error.

    I think this is one of the possible reason/solutions to this problem. It is possible that this exception can be fixed in another way as it can be caused by totally different reason.

提交回复
热议问题