最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android控件之TabHost用法實(shí)例分析

 更新時(shí)間:2015年09月08日 22:22:32   投稿:mdxy-dxy  
這篇文章主要介紹了Android控件之TabHost用法,以完整實(shí)例形式較為詳細(xì)的分析了TabHost控件實(shí)現(xiàn)選項(xiàng)卡的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了Android控件之TabHost用法。分享給大家供大家參考。具體如下:

以下通過(guò)TabHost實(shí)現(xiàn)android選項(xiàng)卡。

main.xml布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <LinearLayout android:id="@+id/tab01"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:gravity="center_horizontal"
  android:orientation="vertical">
  <ImageView android:id="@+id/iv01" 
    android:scaleType="fitXY"
    android:layout_gravity="center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/andy"/>
   <TextView android:id="@+id/tv01"
    android:layout_width="wrap_content" 
   android:layout_height="wrap_content"
   android:textSize="24dip" 
   android:text="Android的創(chuàng)造者: Andy Rubin"/>
 </LinearLayout>
 <LinearLayout android:id="@+id/tab02"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:gravity="center_horizontal"
  android:orientation="vertical">
  <ImageView android:id="@+id/iv02" 
    android:scaleType="fitXY"
    android:layout_gravity="center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/bill"/>
   <TextView android:id="@+id/tv02"
    android:layout_width="wrap_content" 
   android:layout_height="wrap_content"
   android:textSize="24dip"
   android:text="Java創(chuàng)造者之一: Bill Joy"/>
 </LinearLayout>
 <LinearLayout android:id="@+id/tab03"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:gravity="center_horizontal"
  android:orientation="vertical">
  <ImageView android:id="@+id/iv03" 
    android:scaleType="fitXY"
    android:layout_gravity="center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/torvalds"/>
   <TextView android:id="@+id/tv03"
    android:layout_width="wrap_content" 
   android:layout_height="wrap_content"
   android:textSize="24dip"
   android:text="Linux之父: Linus Torvalds"/>
 </LinearLayout>
</LinearLayout>

TabHostActivity類:

package com.ljq.activity;
import android.app.TabActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.TabHost;
public class TabHostActivity extends TabActivity{
 private TabHost tab=null;
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  tab=this.getTabHost();
  LayoutInflater.from(this).inflate(R.layout.main, tab.getTabContentView(), true);
  tab.addTab(tab.newTabSpec("選項(xiàng)卡一").setIndicator("選項(xiàng)卡一", 
     getResources().getDrawable(R.drawable.png1)).setContent(R.id.tab01));
  tab.addTab(tab.newTabSpec("選項(xiàng)卡二").setIndicator("選項(xiàng)卡二", 
    getResources().getDrawable(R.drawable.png2)).setContent(R.id.tab02));
  tab.addTab(tab.newTabSpec("選項(xiàng)卡三").setIndicator("選項(xiàng)卡三", 
    getResources().getDrawable(R.drawable.png3)).setContent(R.id.tab03));
 }
}

運(yùn)行結(jié)果:

希望本文所述對(duì)大家的Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

曲松县| 临沧市| 鸡东县| 哈尔滨市| 洪洞县| 孟津县| 宜城市| 昌江| 武安市| 宣城市| 临安市| 十堰市| 西充县| 龙门县| 扶风县| 波密县| 丹棱县| 海晏县| 县级市| 施甸县| 中方县| 襄樊市| 河东区| 岑巩县| 隆子县| 瓦房店市| 儋州市| 清河县| 襄汾县| 宜宾市| 潞城市| 手游| 广南县| 东安县| 西城区| 武隆县| 台州市| 同仁县| 武宁县| 安平县| 县级市|