首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Tabhost嵌套以及Tab中兑现多个Activity跳转的使用

2012-06-21 
Tabhost嵌套以及Tab中实现多个Activity跳转的使用在网上查了一些资料,明白了Tabhost嵌套和Tab里实现多个Ac

Tabhost嵌套以及Tab中实现多个Activity跳转的使用
      在网上查了一些资料,明白了Tabhost嵌套和Tab里实现多个Activity的跳转原理,自己做了一个demo,源码 如下:

  • <?xml version="1.0" encoding="utf-8"?>  <TabHost xmlns:android="http://schemas.android.com/apk/res/android"  
  •     android:id="@android:id/tabhost" android:layout_width="fill_parent"      android:layout_height="fill_parent"  
  •     android:background="@drawable/ch">      <LinearLayout android:orientation="vertical"  
  •         android:layout_width="fill_parent" android:layout_height="fill_parent">          <TabWidget android:id="@android:id/tabs"  
  •             android:layout_alignParentBottom="true" android:layout_width="fill_parent"              android:layout_height="wrap_content"/>  
  •         <FrameLayout android:id="@android:id/tabcontent"              android:layout_weight="1" android:layout_width="fill_parent"  
  •             android:layout_height="fill_parent" />      </LinearLayout>  
  • </TabHost>    
  • ////////////////////////////////////////////////////////    
  • <?xml version="1.0" encoding="utf-8"?>  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  •     android:layout_width="match_parent"      android:layout_height="match_parent"  
  •     android:orientation="vertical" >      <TextView  
  •         android:id="@+id/text1"          android:layout_width="wrap_content"  
  •         android:layout_height="wrap_content"          android:text="这是tab的第二个界面">  
  •     </TextView>        
  • </LinearLayout>    
  • //////////////////////////////////////////////////////    
  • <?xml version="1.0" encoding="utf-8"?>  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  •     android:layout_width="match_parent"      android:layout_height="match_parent"  
  •     android:orientation="vertical" >      <TextView  
  •         android:id="@+id/text1"          android:layout_width="wrap_content"  
  •         android:layout_height="wrap_content"          android:text="这是tab的第一个界面">  
  •     </TextView>       <Button android:id="@+id/btn"     
  •         android:layout_width="wrap_content"            android:layout_height="wrap_content"    
  •         android:text="跳转 "/>        
  • </LinearLayout>    
  • //////////////////////////////////////////////////////    
  • <?xml version="1.0" encoding="utf-8"?>  <TabHost xmlns:android="http://schemas.android.com/apk/res/android"  
  •     android:id="@+id/mytabhost" android:layout_width="fill_parent"      android:layout_height="fill_parent"  
  •     android:background="@drawable/yt">      <LinearLayout android:orientation="vertical"  
  •         android:layout_width="fill_parent" android:layout_height="fill_parent">          <!-- 注意FrameLayout\TabWidget标签的位置-->  
  •                   <FrameLayout android:id="@android:id/tabcontent"  
  •             android:layout_weight="1" android:layout_width="fill_parent"              android:layout_height="fill_parent" >  
  •                 <TextView                      android:id="@+id/widget59"  
  •                     android:layout_width="wrap_content"                      android:layout_height="wrap_content"  
  •                     android:text="苹果IOS?"                      android:layout_alignParentTop="true"  
  •                     android:layout_centerHorizontal="true"                      >  
  •                     </TextView>                      <TextView  
  •                     android:id="@+id/widget60"                      android:layout_width="wrap_content"  
  •                     android:layout_height="wrap_content"                      android:text="谷歌Android"  
  •                     android:layout_alignParentTop="true"                      android:layout_alignParentRight="true"  
  •                     >                      </TextView>  
  •         </FrameLayout>          <TabWidget android:id="@android:id/tabs"  
  •             android:layout_alignParentBottom="true" android:layout_width="fill_parent"              android:layout_height="wrap_content"/>  
  •     </LinearLayout>  </TabHost>  

    ///////////////////////////////////////////////////////////////待会补上效果图~


  • 热点排行