android - How to make particular tab in FragmentTabHost has multiple fragment navigations like tabgroupactivity -


i created 3 tabs using fragmenttabhost. need make navigation under tabs. how can this. need get using tabgroupactivity.

tab1 --->frag1-->frag2

tab2 --->frag3

tab3 --->frag4--->frag5

i have used fragmenttransaction.add(), fragmenttransaction.remove(), fragmenttransaction.replace(). these 3 methods nothing give solution.

replace method shows new fragment view on top of existing fragment view.

remove , add, these 2 remove works, add not works.

thanks in advance.

tabhostmain.java

    @override     protected void oncreate(bundle savedinstancestate)  {      super.oncreate(savedinstancestate);     setcontentview(r.layout.bottom_tabs);  mtabhost = (fragmenttabhost) findviewbyid(android.r.id.tabhost);                 mtabhost.setup(this, getsupportfragmentmanager(), r.id.realtabcontent);             view view;     view=gettabview(r.drawable.ic_launcher);      bundle b = new bundle();     b.putstring("key", "simple");     mtabhost.addtab(mtabhost.newtabspec("simple").setindicator(view),fragment1.class, null);      b = new bundle();     b.putstring("key", "contacts");     view=gettabview(r.drawable.ic_launcher);     mtabhost.addtab(mtabhost.newtabspec("contacts").setindicator(view), fragment2.class, null);      b = new bundle();     b.putstring("key", "custom");     view=gettabview(r.drawable.ic_launcher);     mtabhost.addtab(mtabhost.newtabspec("custom").setindicator(view),fragment3.class, null);  } 

fragment3.java

@override     public view oncreateview(layoutinflater inflater, viewgroup container,bundle savedinstancestate) {          view view=layoutinflater.from(getactivity()).inflate(r.layout.activity_second, null);          ((textview)view.findviewbyid(r.id.second_act_text)).setonclicklistener(new onclicklistener() {              @override             public void onclick(view v) {                 fragmentmanager fm=getchildfragmentmanager();                 fragmenttransaction fragmenttransaction=fm.begintransaction();                 fragmenttransaction.replace(r.id.second_activity, new fragment1()).addtobackstack(null).commit();             }         });         return view;     } 

the concept of different fragment navigation stacks in each tab has been discussed quite few times on stackoverflow, 1 example instance:

separate stack each tab in android using fragments

one simple/crude way of achieving without having manage own custom navigation stack have root fragment under each tab, , whenever root fragment wants navigate fragment (fragment b) show new activity fragment b , activity have own fragment navigation stack.

tab1 --->root frag1 --> activity (own nav stack) --> frag2

tab2 --->root frag3

tab3 --->root frag4 --> activity (own nav stack) --> frag5 --> frag6 --> frag7

an example of app stackanywhere app. makes heavy use of tabs, when navigate within tabs moves navigation new activity. ymmv approach, however.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -