0

If I add new Item to wishlist RecyclerView can added only at last row, but i want to display at top of 0th position in RecyclerView. I tried to display first position of RecyclerView, but Its doesn't workout well.

Code

 data.add(new CartitemModel(prodcutname, product_alias, MRPPRICE, SALES, OFFER, imagone, productid));
 wishadapter = new WishlistAdapter(data, wishlist_Items.this);
 recyleitems.setAdapter(wishadapter);
 wishadapter.notifyItemInserted(0);
Nivethitha
  • 91
  • 1
  • 3
  • 16

1 Answers1

3

You have a list of items. When you want to add another item to the top use

  data.add(0,new CartitemModel(prodcutname, product_alias, MRPPRICE, SALES, OFFER, imagone, productid));
  wishadapter.notifyItemInserted(0);

This will work as now you are adding the item to top of list.

Ragesh Ramesh
  • 3,470
  • 2
  • 14
  • 20