How can I empty a RecyclerView before refilling it?

0

I have a RecyclerView in which I load the messages of a chat, and what I need is that when the user connects to Internet , the RecyclerView erases the messages that you have already saved and add the new ones that are obtained from Firebase . I do not know how I can do this, I do not know if I should create a custom adapter in Null or something else.

I hope you can help me!

    
asked by Rosyec Parrado 04.09.2018 в 21:46
source

1 answer

1

What you should do is the following

public void borrarData() {
       myList.clear(); //Borras la data con la que llenas el recyclerview
       mAdapter.notifyDataSetChanged(); //le notificas al adaptador que no hay nada para llenar la vista 
}

Execute this method when you know you have internet or after verifying that the user has a connection

    
answered by 05.09.2018 / 15:30
source