android使用tabhost实现导航
生活随笔
收集整理的這篇文章主要介紹了
android使用tabhost实现导航
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
參考
?
http://blog.csdn.net/xixinyan/article/details/6771341
http://blog.sina.com.cn/s/blog_6b04c8eb0101a2ej.html
xml
<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"><LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"android:layout_weight="1"> <!-- 將導(dǎo)航欄tab放置底部 --><FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" /> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content"android:background="@color/chocolate" android:textColor = "@color/darkgray"android:layout_marginBottom="-3dip" /> <!-- "去掉最下方的亮色條" --></LinearLayout> </TabHost>?
java
public class MainTab extends TabActivity {ActionBar actionBar;boolean isExit;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.mainintent);actionBar = getActionBar();actionBar.hide();// 獲取該Activity里面的TabHost組件TabHost tabHost = getTabHost();// 使用Intent添加第一個(gè)Tab頁(yè)面tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("AA") // ,getResources().getDrawable(R.drawable.ic_launcher)).setContent(new Intent(this, AA.class)));// 使用Intent添加第二個(gè)Tab頁(yè)面tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("BB").setContent(new Intent(this, BB.class))); }// 設(shè)置TabHost的背景顏色tabHost.setBackgroundColor(Color.argb(150, 22, 70, 150));// 設(shè)置TabHost的背景圖片資源// mTabHost.setBackgroundResource(R.drawable.bg0);// 設(shè)置當(dāng)前顯示哪一個(gè)標(biāo)簽tabHost.setCurrentTab(0);?
?
轉(zhuǎn)載于:https://www.cnblogs.com/sudawei/p/3435001.html
總結(jié)
以上是生活随笔為你收集整理的android使用tabhost实现导航的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: win7电脑磁盘文件以分组方式展现解决方
- 下一篇: iis 重新安装后 重新注册asp.ne