android - Update the current fragment in FragmentPagerAdapter -


i have viewpager tab indicator. viewpager setadaper fragmentpageradapter.

i have little understanding how internals of fragmentpageradapter work. noticed neighbor fragments resumed ( onresume called ) , though neighbor not yet visible.

i put update methods in onresume thinking once fragment current, updated.

ad banner refresh
i want ad banner set in footer update when swiping left once or swipping once right . neighbor fragments not recreated ( thing ). onresume called avoiding banner refresh. method loadbannerad in onresume() method.



how can call method loadbannerad() current fragment by method inside fragment ?

edit : know mviewpager.setonpagechangelistener() .

    onpagechangelistener monpagechangelistener = new viewpager.onpagechangelistener() {          @override         public void onpageselected(int position) {         // method can called before fragment 's oncreateview()         }          ....     }; 

but there danger when fragment has not been created yet . managing whether fragment has been created or not in activty defeats purepose of it.

enter image description here

you use:

mviewpager.setonpagechangelistener(new onpagechangelistener() {              @override             public void onpageselected(int index) {                 // todo auto-generated method stub              }              @override             public void onpagescrolled(int arg0, float arg1, int arg2) {                 // todo auto-generated method stub              }              @override             public void onpagescrollstatechanged(int arg0) {                 // todo auto-generated method stub              }         }) 

then can handle happens in onpageselected(int index).


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -