java - Recycler view inside view pager not refreshing when page scrolled -


i have recyclerview inside viewpager. when scroll view pager content in recyclerview not correct. tried call notifydatasetchanged() in onpagescrolled() , onresume(). still content not refreshing when page scrolled.

how solve problem? in advance

viewpager.setonpagechangelistener(new viewpager.onpagechangelistener() {     @override     public void onpagescrolled(int position, float positionoffset, int positionoffsetpixels) {       //viewpager.setoffscreenpagelimit(app.getinstance().getfragmentlist().size());         favlistadapter.notifydatasetchanged();          }     @override     public void onpageselected(int position) {          //favlistadapter.notifydatasetchanged();         }     @override     public void onpagescrollstatechanged(int state) {     });   @override public void onresume(){     if(favlistadapter!=null){         favlistadapter.notifydatasetchanged();      }     super.onresume(); } 

edit:

i inflating view this:

@override public recyclerview.viewholder {      oncreateviewholder(final viewgroup viewgroup, int viewtype) {       view v1 = layoutinflater.from(viewgroup.getcontext()).inflate(r.layout‌​.item_add, viewgroup, false);      return new cellviewholder(v1);       } } 

i think problem content(recyclerview) inside viewpager not getting dynamic data should called when recyclerview shown on screen.

it's because viewpager loads page left , right of current page soft transition.

so, should rather call method changes recyclerview's contents on onpagescrolled of viewpager.onpagechangelistener.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -