notifyDataSetChange not working on RecyclerView [duplicate] notifyDataSetChange not working on RecyclerView [duplicate] android android

notifyDataSetChange not working on RecyclerView [duplicate]


My issue was that I was not notifying the change on the main thread, therefore the change was not visible right away. It is the same issue pointed out here.


I was trying to update RecycleView with notifyDataSetChanged() method in response to com.google.common.eventbus.Subscribe.

Like @wmora mentioned the problem was that the notify method was not called in the main UI thread.

I resolved it with AndroidAnnotations' @UiThread

@UiThreadprotected void dataSetChanged() {    notifyDataSetChanged();}

which is equivalent to:

 final Adapter adapter = this; new Handler(Looper.getMainLooper()).post(new Runnable() {    @Override    public void run() {       adapter.notifyDataSetChanged();    } });

note: just separate new Handler into class private field