Skip to content
Advertisement

recyclerview uploads items multiple time on refresh

I have implemented a recyclerview, where I want to show the groups that have been created in the app. Right now I am refreshing the recyclerview using the swipeRefreshLayout, but everytime I refresh the recyclerview, it prints out the same group multiple times according to how many times I refresh it.

Can anyone help me solve this problem?

Below is the code.

onCreateView method:

JavaScript

recyclerUpdate function, where Strings are added to the recyclerView adapter:

JavaScript

recyclerViewAdapter:

JavaScript

}

Thank you in advance!

Advertisement

Answer

You are adding new items to mProjects and mProjectsId not clearing these lists. Add clear() before for loop:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement