android - Keep 'distant' Fragments updated and ready for users in a ViewPager -


i have couple of fragments recyclerviews in viewpager. on actions in first fragment, remaining fragments change display.

i can access fragments first 1 , call update methods on them. problem is, updates not happen if not swipe other fragments. in fact, before tapping action buttons in first fragment, have swipe other fragments (without purpose) keep app crashing nullpointerexception.

the reason guess because remaining fragments null not brought view.

i have tried approach far, in vain:

public void updatepager(int pageposition) {     ((nmmain) getactivity()).dsfragment.updatedsfragment(dview);      nmparentviewpager = (viewpager) getactivity().findviewbyid(r.id.gssupremepager);     nmparentviewpager.getadapter().notifydatasetchanged();     nmparentviewpager.setcurrentitem(pageposition, true); } // of updatepager() 

log

after clicking action buttons in fragment1 after swiping fragments:

02-06 14:53:21.563 7765-8678/com.my a/nmdbhelper class: create view-1 query: create view view_temp 02-06 14:53:21.585 7765-8678/com.my a/nmdbhelper class: create dealsview-2 query: create table d_view 02-06 14:53:21.748 7765-7765/com.my e/dsfragment: in frag2.updatefragment(): dview.size() = 3

after clicking action buttons in fragment1 without swiping fragments:

02-06 14:58:52.691 11967-11967/com.nearme e/androidruntime: fatal exception: main process: com.my, pid: 11967 java.lang.nullpointerexception @ com.my.s.frag2.updatepager(frag2.java:xxx)

so question,

  • irrespective of visibility of fragment in viewpager, how can (fragments) kept ready latest content?

the way thinking , way worded question - oh complex.

all looking pre-load fragment pages. this post resolved it. so, viewpager.setoffscreenpagelimit() answer.

though not my answer, hope bumps similar complexity , lands here.

thanks looking in, @cricket_007 , others.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -