Reputation: 1681
Following my recent visit to Firestore I try to use Firebase-UI's RecyclerView but I cannot find a way to add a new element to a certain position.
Here's how I did with a basic RecyclerView:
mDataset.add(position,elenmet);
mAdapter.notifyItemInserted(position);
mAdapter.notifyDataSetChanged();
I found this method mRecyclerView.addView(view, position);
but I do not have a view, only of my element which is an object of the same type as the others.
Upvotes: 1
Views: 171
Reputation: 139019
There is no need to call mAdapter.notifyDataSetChanged();
. To add an element to a specific position and to notify the adapter, this line of code is not needed at all. To solve this, just remove it from your code. The adapter is already notified using:
mAdapter.notifyItemInserted(position);
Upvotes: 1