android how to press a tab in FragmentTabHost to get to FragmentActivity instead of another Fragment -


i want make app 3 tabs @ bottom. in app want each tab click open fragmentactivity have viewpager, can swipe activities finger still remains in same tab. right now, each tab open fragment cant use view pager. how open fragment activity fragmenttabhost? code, thanks!

public class mainactivity extends fragmentactivity {  private fragmenttabhost mtabhost;  @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);      bundle b = new bundle();     b.putstring("key", "one");     mtabhost.addtab(mtabhost.newtabspec("one").setindicator("one"),             fragment1.class, b);     //     b = new bundle();     b.putstring("key", "two");     mtabhost.addtab(mtabhost.newtabspec("two")             .setindicator("two"), fragment2.class, b);     b = new bundle();     b.putstring("key", "three");     mtabhost.addtab(mtabhost.newtabspec("three").setindicator("three"),             fragment3.class, b); } 

this fragment example

    public class fragment1 extends fragment {  private textview text;  public fragment1() {     // todo auto-generated constructor stub  }  @override public void oncreate(bundle savedinstancestate) {     // todo auto-generated method stub     super.oncreate(savedinstancestate); }  @override public view oncreateview(layoutinflater inflater, viewgroup container,         bundle savedinstancestate) {     // todo auto-generated method stub     view v = layoutinflater.from(getactivity()).inflate(r.layout.layout,             null);     text = (textview) v.findviewbyid(r.id.text);     if (getarguments() != null) {         //         try {             string value = getarguments().getstring("key");             text.settext("this first tab - " + value);         } catch (exception e) {             // todo auto-generated catch block             e.printstacktrace();         }     }     return v; }  @override public void onactivitycreated(bundle savedinstancestate) {     // todo auto-generated method stub     super.onactivitycreated(savedinstancestate); } //     } 

and xml

<framelayout     android:id="@+id/realtabcontent"     android:layout_width="match_parent"     android:layout_height="0dip"     android:layout_weight="1" >  </framelayout> <android.support.v4.app.fragmenttabhost     android:id="@android:id/tabhost"           android:background="@android:color/darker_gray"      android:layout_width="match_parent"     android:layout_height="wrap_content" >      <framelayout         android:id="@android:id/tabcontent"          android:layout_width="0dp"         android:layout_height="0dp"         android:layout_weight="0" /> </android.support.v4.app.fragmenttabhost> 


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -