fragment tab host - Android : passing parameters to a tab -
in android app, use following code create tabs :
mtabhost = (fragmenttabhost)findviewbyid(android.r.id.tabhost); mtabhost.setup(this, getsupportfragmentmanager(), r.id.realtabcontent); mtabhost.addtab(mtabhost.newtabspec("simple").setindicator("simple"), myfragment.class, null); in addtab method, third parameter bundle object , null. use third parameter pass parameters fragment ?
the android api documentation empty addtab , not document parameter.
the answer yes. parameters passing in bundle later set fragment arguments , can accessed getarguments inside fragment.
the code makes happen in fragmenttabhost :
newtab.fragment = fragment.instantiate(mcontext, newtab.clss.getname(), newtab.args);
Comments
Post a Comment