I would like to add CardView to an empty RecyclerView list by clicking button. Clicking button again will move the initial CardView down and the next generic CardView will be added to the top of the list.
CodePudding user response:
Create a method and then call it:
if (mAdapter != null) {
mAdapter.addItem(0, whatever);
mAdapter.notifyItemChanged(0)
mRecyclerView.scrollToPosition(0);
}