android - Navigation Type (Fixed Tabs + Swipe) -


in application have tabhost tabwidget have several tabs. need tab show me inside tabcontent schedule grid allow swipe right , left move through months. need tab stay fixes , schedule swipes.

the navigation type (fixed tabs + swipe) allow me that? understand navigation allow swipe tab don't stay same.

what need possible? , attention.

i possible, stay codes on tabhost , tabwidget.

so assume 1 of tabs calling activity named schedule.class, default tabhost not allow swiping change tab feature, fine.

so in schedule activity, using viewpager, learnt how use article: http://thepseudocoder.wordpress.com/2011/10/05/android-page-swiping-using-viewpager/

which pretty easy understood. may try use it, hope answered question

update: here's sample

schedule.class

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.schedule);      viewpager viewpager = (viewpager) findviewbyid(r.id.viewpager);      list<fragment> fragments = new arraylist<fragment>();     fragments.add(fragment.instantiate(this, fragment1.class.getname()));     fragments.add(fragment.instantiate(this, fragment2.class.getname()));     fragments.add(fragment.instantiate(this, fragment3.class.getname()));      myfragmentadapter miscfragmentadapter = new myfragmentadapter(getsupportfragmentmanager(), fragments);      viewpager.setadapter(miscfragmentadapter); } 

myfragmentadapter.class

public class myfragmentadapter extends fragmentpageradapter {      private list<fragment> fragments;      public miscfragmentadapter(fragmentmanager fragmentmanager, list<fragment> fragments) {         super(fragmentmanager);         this.fragments = fragments;     }      @override     public fragment getitem(int position) {         return this.fragments.get(position);     }      @override     public int getcount() {         return this.fragments.size();     } } 

schedule.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent">      <android.support.v4.view.viewpager         android:id="@+id/viewpager"         android:layout_width="fill_parent"         android:layout_height="fill_parent" />  </linearlayout> 

fragment1.class or fragment2.class or fragment3.class

public class fragment1 extends fragment {      @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         if (container == null) {             // have different layouts, , in 1 of them             // fragment's containing frame doesn't exist.  fragment             // may still created saved state, there             // no reason try create view hierarchy because             // won't displayed.  note not needed --             // run code below, create , return             // view hierarchy; never used.             return null;         }         return (linearlayout) inflater.inflate(r.layout.fragment1, container, false);     } } 

fragment1 simple layout whatever want inside it.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -