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

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

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

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

以下通過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é)果:

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

相關(guān)文章

最新評論

盐城市| 巴中市| 安泽县| 西吉县| 扬中市| 彭泽县| 四会市| 沛县| 华蓥市| 旺苍县| 宜川县| 巴东县| 和林格尔县| 手游| 南部县| 麟游县| 宜黄县| 黑山县| 庐江县| 长宁区| 石家庄市| 洪雅县| 大同县| 左云县| 方城县| 阿克苏市| 门头沟区| 衡阳市| 云安县| 屯门区| 革吉县| 泊头市| 阿城市| 咸丰县| 通河县| 芷江| 通州区| 遂溪县| 河津市| 南丹县| 铁岭县|