android - When (& where) are my fragments created -
i'm using viewpagerindicator library (http://viewpagerindicator.com/) create sort of wizard android app. works fine , want.
i "extend" functionality bit having "previous"/"next" buttons in actionbar - pretty in android's "done bar" tutorial - step through wizard. works charm, too.
however: display information "next" & "previous" fragment in actionbar's buttons. information pass fragments live in viewpager @ time of "creation" (actually @ time of object instantiation - using classical "newinstance(...)" approach create instance of fragment, store parameters in bundle , extract them in fragment's "oncreate" method). same way template it, when create new fragment project.
so, information thing want display in wizards button know fragment next , last.
the type of information not important problem. string or icon or int or ... else want.
however, wherever i've tried access fragments data, fragment has not yet been initialized (meaning "oncreate" method has not been called yet).
i've tried in host fragment's "onviewcreated" method, because thought that's subviews should initialized (at least "oncreate" method should have been called, thought), seems handled differently viewpager retain number of fragments in memory set setoffscreenpagelimit.
so, i'm looking (and missing) correct callback method here. 1 called when viewpager's next fragments have been loaded , initialized. if such callback exists, place little piece of code there update text in "previous"/"next" buttons within actionbar.
any help, comments, ideas highly appreciated. if needed, can try attach code sample better explain setup, think should easy enough understand problem is.
thanks in advance!
p.s.: tried using eventbus send "onfragmentinitialized" messages fragments within in viewpager , hosting fragment. worked, not seems proper way this.
when fragment's oncreate method called, preparing displayed, , practically past point considered next or previous fragment instead considered current.
a fragment's oncreateviews method called after committing transaction in fragmentmanager. takes less 1 sec bring in front of user (depending on device , runtime environment)
but in case, data should initalized outside fragment uses it, , displayed ever want passing data displaying whatever want form it.
decouple data android objects (fragment, activity ...) , should able load, maintain, access cleanly , without worrying callbacks.