0

I am working with viewPager where lets say I have 3fragmentsout of that one is in focus so when I perform any operations likeloadordelete` the operation executes in the page on focus for the time and need to refresh the app in order for the other pages to perform the operation.

Can anyone please let me know how do i make it perform a same task instantly when I call it from either of the pages

I have came across this question stackoverflow question but here they are deleting the fragments but all I need to do is refresh all so all perform the given operation when it's been given.

I have also came across this question Stackoverflow question 2 but here it's re- doing everything thus not efficient at all

Tried the following code, it worked, but it's lagging

pager.getAdapter().notifyDataSetChanged();//with the pager adapter "position_none" <------ laggy

Got the solution that I was looking for in case anyone of you is looking for the same here is the link.

Community
  • 1
  • 1
silverFoxA
  • 4,013
  • 6
  • 28
  • 67

2 Answers2

0

Looks like all you need is change offsetPageLimit to number of your fragments. But this is not an only way. I'll suggest you to use Loaders for updating information in your Fragments. Cursor loader is a good example how auto updating could work after data changes in SQLite table. But if you don't use SQLite you'll need to implement your own loader.

Stepango
  • 4,413
  • 3
  • 29
  • 43
  • well i am using sqlite and depending on the pages i am updating the page it works fine for the page thats not yet been created but for the 2 pages other than the one in focus won't update instantly – silverFoxA May 03 '15 at 05:41
0

May be you should do custom interface for refresh event(With some method like doRefresh()). Then make each fragment implement that interface and in the activity add method refreshAll(), which calls doRefresh for every fragment.

bahakz
  • 373
  • 4
  • 9