android - How to add list of new items to recycler view for exisitng list without moving to top of list -


i trying implement pagination application , partially successful. when call server 6 items , adding items recyclerview. when user comes , scrolls @ last item making call server , fetching page 2 items , adding new items existing list.

here able add new items successfully. problem calling adapter.notifydatasetchanged(), hence goes first item after adding new items.

how can stop going top of list, should call other adapter.notifydatasetchanged()? below code of setting adapter

toadlineadapter = new toadlineadapter(mcontext, getdata()); recyclerview.setadapter(toadlineadapter); toadlineadapter.notifydatasetchanged(); toadlineadapter.setclicklistener(this); recyclerview.setlayoutmanager(new linearlayoutmanager(getactivity())); 

no need notify when initializing adapter:

toadlineadapter = new toadlineadapter(mcontext, getdata()); recyclerview.setadapter(toadlineadapter); // remove below line //   toadlineadapter.notifydatasetchanged(); toadlineadapter.setclicklistener(this); recyclerview.setlayoutmanager(new linearlayoutmanager(getactivity())); 

and notify when adding items, ex:

yourlist.add(yourobject); toadlineadapter.notifydatasetchanged(); 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -