android - horizontal scrolled view for tabwiget not slide tabs -


i using horizontal scrolled view tabs not slide content change. please me. when flip pages tabs not flip.

<linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="vertical"         >         <tabwidget             android:id="@android:id/tabs"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             >         </tabwidget>          <framelayout             android:id="@android:id/tabcontent"             android:layout_width="match_parent"             android:layout_height="match_parent" >             <framelayout                 android:id="@+id/tab1"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:visibility="gone" />             <framelayout                 android:id="@+id/tab2"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:visibility="gone" /> 

//

tabwidget tw = (tabwidget) rootview.findviewbyid(android.r.id.tabs); linearlayout ll = (linearlayout) tw.getparent(); horizontalscrollview hs = new horizontalscrollview(getactivity()); hs.setlayoutparams(new framelayout.layoutparams(framelayout.layoutparams.match_parent, framelayout.layoutparams.wrap_content)); ll.addview(hs, 0); ll.removeview(tw); hs.addview(tw); hs.sethorizontalscrollbarenabled(false); hs.setfillviewport(true); 

when flip pages tabs not flip.

you need use tabhost think. @ this link can find more 30 examples use tabhost , tabwidget @ sample layout , should change code according examples. there simple example : http://www.learn-android-easily.com/2013/07/android-tabwidget-example.html

<tabhost     android:id="@android:id/tabhost"     android:layout_width="fill_parent"     android:layout_height="fill_parent"      >     <linearlayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:orientation="vertical"        >        <tabwidget         android:id="@android:id/tabs"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         >     </tabwidget>      <framelayout         android:id="@android:id/tabcontent"         android:layout_width="match_parent"         android:layout_height="match_parent" >         <framelayout             android:id="@+id/tab1"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:visibility="gone" />         <framelayout             android:id="@+id/tab2"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:visibility="gone" />             .             .             .     </linearlayout> </tabhost> 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -