Android refresh Recyclerview delayed -
i have simple layout recyclerview. in oncreateview method set recyclerview:
@override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_overview, container, false); recyclerview = (recyclerview) rootview.findviewbyid(r.id.rv_overview); list = new arraylist<>(); linearlayoutmanager layoutmanager = new linearlayoutmanager(getactivity()); layoutmanager.setorientation(linearlayoutmanager.vertical); recyclerview.setlayoutmanager(layoutmanager); list = getoverviewlist(getactivity()); adapter = new overviewrecycleradapter(getactivity(), list); recyclerview.setadapter(adapter); final context context = getactivity(); new handler().postdelayed(new runnable() { @override public void run() { list =getoverviewlist(context); adapter.notifydatasetchanged(); } }, 1000); return rootview; }
as can see recyclerview needs refreshed second after view creted. tried achieve thsi handler. code within handler not refresh recyclerview. should.
but should.
no shouldn't, cause not setting new data adapter
list =getoverviewlist(context);
you setting variable new list, doesn't change old list in adapter
edit:
try
list.clear(); list.addall(getoverviewlist(context));
Comments
Post a Comment