android - Add the new items display top of position in Recycler View -


if add new item wishlist recyclerview can added @ last row, want display @ top of 0th position in recyclerview. tried display first position of recyclerview, 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); 

you have list of items. when want add item top use

  data.add(0,new cartitemmodel(prodcutname, product_alias, mrpprice, sales, offer, imagone, productid));   wishadapter.notifyiteminserted(0); 

this work adding item top of list.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -