i've created viewpager 8 fragments use same xml layout. however, want different fragments use different content. need id of whatever fragment can load specific content onto fragment.
i've tried
extras.putint(globals.key_category_position, position); fragment.setarguments(extras);
in getitem(int position) method on fragmentpageradapter.
then, position of fragment in fragment class. when this, go 0 7 when print out position of each fragment of them increment 7 become same fragment.
is there other way id each fragment?
here quite nice example:
when creating fragment:
bundle args = new bundle(); args.putint("num", num); f.setarguments(args);
and in fragment:
@override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mnum = getarguments() != null ? getarguments().getint("num") : 1; }
Comments
Post a Comment