公交车上荫蒂添的好舒服的电影-公用玩物(np双xing总受)-公用小荡货芊芊-公与妇仑乱hd-攻把受做哭边走边肉楼梯play-古装一级淫片a免费播放口

LOGO OA教程 ERP教程 模切知識交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網站管理員

【Android】--底部Tab的實現(xiàn)

admin
2013年2月25日 14:40 本文熱度 4819

國際慣例先上圖:




tabhost布局文件,注意tabhost,tabcontent和tabs這三個id一定要正確





[html]


  1. xml version="1.0" encoding="utf-8"?>  

  2. <TabHost xmlns:android="http://schemas.android.com/apk/res/android"  

  3.     android:id="@android:id/tabhost"  

  4.     android:layout_width="match_parent"  

  5.     android:layout_height="match_parent" >  

  6.     <RelativeLayout android:orientation="vertical"    

  7.         android:layout_width="match_parent"   

  8.         android:layout_height="match_parent">  

  9.         <FrameLayout android:id="@android:id/tabcontent"    

  10.                 android:layout_width="match_parent"   

  11.                 android:layout_height="match_parent" />  

  12.             <TabWidget android:id="@android:id/tabs"  

  13.                 android:layout_width="match_parent"  

  14.                 android:layout_height="wrap_content"   

  15.                 android:background="@drawable/selector"  

  16.                 android:layout_alignParentBottom="true">  

  17.             TabWidget>  

  18.     RelativeLayout>  

  19. TabHost>  
每一個tab項的布局文件,上面圖片下面是文字,





[html]


  1. xml version="1.0" encoding="utf-8"?>  

  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  

  3.     android:layout_width="match_parent"  

  4.     android:layout_height="match_parent"  

  5.     android:orientation="vertical" >  

  6.     <ImageView android:id="@+id/tab_iv_icon"  

  7.         android:layout_width="match_parent"   

  8.         android:layout_height="28.0dip"   

  9.         android:scaleType="fitCenter"/>  

  10.     <TextView android:id="@+id/tab_tv_text"  

  11.         android:layout_width="match_parent"   

  12.         android:layout_height="wrap_content"   

  13.         android:textSize="12.0sp"   

  14.         android:textColor="#FFFFFF"  

  15.         android:ellipsize="marquee"   

  16.         android:gravity="center"   

  17.         android:singleLine="true"   

  18.         android:marqueeRepeatLimit="1"/>  

  19. LinearLayout>  
最后是MainActivity繼承自TabActivity





[java]


  1. public class MainActivity extends TabActivity {  

  2.     private TabHost tabHost;  

  3.     private static final String HOME = "主頁";    

  4.     private static final String REFER = "提及";    

  5.     private static final String ABOUT = "關于";  

  6.     private static final String SEARCH = "搜索";    

  7.     private static final String MORE = "更多";   

  8.     //內容Intent   

  9.     private Intent homeIntent;  

  10.     private Intent referIntent;  

  11.     private Intent aboutIntent;  

  12.     private Intent searchIntent;  

  13.     private Intent moreIntent;  

  14.   

  15.     public void onCreate(Bundle savedInstanceState) {  

  16.         super.onCreate(savedInstanceState);  

  17.         setContentView(R.layout.tabhost);//設置TabHost使用的布局文件   

  18.           

  19.         tabHost=this.getTabHost();  

  20.         tabHost.setFocusable(true);  

  21.         prepareIntent();  

  22.         setupIntent();  

  23.           

  24.     }  

  25.       

  26.     private void setupIntent(){  

  27.         tabHost.addTab(buildTabSpec(HOME,R.drawable.icon_1_n, homeIntent));  

  28.         tabHost.addTab(buildTabSpec(REFER,R.drawable.icon_2_n, referIntent));  

  29.         tabHost.addTab(buildTabSpec(ABOUT,R.drawable.icon_3_n, aboutIntent));  

  30.         tabHost.addTab(buildTabSpec(SEARCH,R.drawable.icon_4_n, searchIntent));  

  31.         tabHost.addTab(buildTabSpec(MORE,R.drawable.icon_5_n, moreIntent));  

  32.     }  

  33.   

  34.     private TabSpec buildTabSpec(String tag, int icon, Intent intent) {  

  35.         View view = View.inflate(MainActivity.this, R.layout.tab, null);  

  36.         ((ImageView)view.findViewById(R.id.tab_iv_icon)).setImageResource(icon);  

  37.         ((TextView)view.findViewById(R.id.tab_tv_text)).setText(tag);  

  38.         return tabHost.newTabSpec(tag)  

  39.                 .setIndicator(view)  

  40.                 .setContent(intent);  

  41.     }  

  42.   

  43.     private void prepareIntent() {  

  44.         homeIntent=new Intent(this, HomeActivity.class);  

  45.         referIntent=new Intent(this, ReferActivity.class);  

  46.         aboutIntent=new Intent(this, AboutActivity.class);  

  47.         searchIntent=new Intent(this,SearchActivity.class);  

  48.         moreIntent=new Intent(this, MoreActivity.class);  

  49.     }  

  50.   

  51. }  

該文章在 2013/2/25 16:37:08 編輯過
關鍵字查詢
相關文章
正在查詢...
點晴ERP是一款針對中小制造業(yè)的專業(yè)生產管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內大量中小企業(yè)的青睞。
點晴PMS碼頭管理系統(tǒng)主要針對港口碼頭集裝箱與散貨日常運作、調度、堆場、車隊、財務費用、相關報表等業(yè)務管理,結合碼頭的業(yè)務特點,圍繞調度、堆場作業(yè)而開發(fā)的。集技術的先進性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點晴WMS倉儲管理系統(tǒng)提供了貨物產品管理,銷售管理,采購管理,倉儲管理,倉庫管理,保質期管理,貨位管理,庫位管理,生產管理,WMS管理系統(tǒng),標簽打印,條形碼,二維碼管理,批號管理軟件。
點晴免費OA是一款軟件和通用服務都免費,不限功能、不限時間、不限用戶的免費OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved

主站蜘蛛池模板: 精品国产片在线免费观看 | www.夜片内射视频日韩精品成人 | 精品丝袜国产自在线拍小草 | 国产亚洲欧美在线播放网站 | 国产精品一区二区电影 | 国产欧美另类久久久精品图片 | 岛国av无码免费无禁网站麦芽 | 国产aⅴ天堂无码一区二区三区 | 国产精品一区二区久久不卡 | 国产午夜无码精品免费看动漫 | 国产一级a级毛片久久久久精品卡 | 国产不卡一区二区免费视 | 91麻豆精品国产片在线观看 | 国产无套内射久久久国产 | 国产精品女人呻吟在线观看 | 国产精品亚洲四区在线观看 | www国产无套内射com | 国产一卡2卡3卡四卡 | 99精品一区无码在线观看 | 国产对白精品刺激一区二区 | 精品欧洲av无码一区二区三区 | 国产成人精品免费视频大全麻豆 | 国产精品视频网站 | 国产成人啪精品午夜在线观看 | 国产麻豆高清在线 | 国产成人免费视频精品一区二 | 国产成人亚洲精品久久 | 国产午夜福利高清小视频合 | 国产成人av乱码免费观看入口 | 精品国产高清露脸在线观看 | 99久久国产综合 | 2025最新国产精品毛片 | 极品少妇高潮一区二区三区99 | 91精品手机 | 风韵丰满熟妇啪啪区老熟 | 国产日韩久久免费福利网站 | 国产美女av一区二区三区 | 2025好看的国产剧推荐 | 韩国高清一区二区午夜无码 | 成人国产综合 | 国产成人精品97 |