欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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用法。分享給大家供大家參考。具體如下:

以下通過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)文章

  • Android Canvas drawText文字居中的一些事(圖解)

    Android Canvas drawText文字居中的一些事(圖解)

    這篇文章主要給大家介紹了關(guān)于Android Canvas drawText文字居中的一些事,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-12-12
  • Android自定義控件之組合控件學(xué)習(xí)筆記分享

    Android自定義控件之組合控件學(xué)習(xí)筆記分享

    這篇文章主要為大家分享了Android自定義控件之組合控件學(xué)習(xí)筆記,具有一定的實(shí)用性和參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-05-05
  • Android繪制簡單條形圖

    Android繪制簡單條形圖

    這篇文章主要為大家詳細(xì)介紹了Android繪制簡單條形圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-08-08
  • Android利用CountDownTimer實(shí)現(xiàn)倒計(jì)時(shí)功能 Android實(shí)現(xiàn)停留5s跳轉(zhuǎn)到登錄頁面

    Android利用CountDownTimer實(shí)現(xiàn)倒計(jì)時(shí)功能 Android實(shí)現(xiàn)停留5s跳轉(zhuǎn)到登錄頁面

    這篇文章主要為大家詳細(xì)介紹了Android利用CountDownTimer實(shí)現(xiàn)倒計(jì)時(shí)功能,Android實(shí)現(xiàn)停留5s跳轉(zhuǎn)到登錄頁面,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • kotlin使用Dagger2的過程全紀(jì)錄

    kotlin使用Dagger2的過程全紀(jì)錄

    Dagger2是一款基于Java注解,在編譯階段完成依賴注入的開源庫,主要用于模塊間解耦,方便進(jìn)行測試。下面這篇文章主要給大家介紹了關(guān)于kotlin使用Dagger2的過程的相關(guān)資料,需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-03-03
  • Android ListView在Fragment中的使用示例詳解

    Android ListView在Fragment中的使用示例詳解

    這篇文章主要介紹了Android ListView在Fragment中的使用,因?yàn)楣ぷ饕恢痹谟胢vvm框架,因此這篇文章是基于mvvm框架寫的,本文通過示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-09-09
  • Android?動(dòng)態(tài)加載?so實(shí)現(xiàn)示例詳解

    Android?動(dòng)態(tài)加載?so實(shí)現(xiàn)示例詳解

    這篇文章主要為大家介紹了Android?動(dòng)態(tài)加載?so實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • Android判斷是否為飛行模式簡單方法

    Android判斷是否為飛行模式簡單方法

    這篇文章主要介紹了Android判斷是否為飛行模式簡單方法,本文使用最簡單的方法實(shí)現(xiàn)判斷是否為飛行模式,需要的朋友可以參考下
    2015-04-04
  • Android中實(shí)現(xiàn)下載和解壓zip文件功能代碼分享

    Android中實(shí)現(xiàn)下載和解壓zip文件功能代碼分享

    這篇文章主要介紹了Android中實(shí)現(xiàn)下載和解壓zip文件功能代碼分享,本文直接給出了實(shí)現(xiàn)代碼,需要的朋友可以參考下
    2015-03-03
  • Android BaseAdapter適配器詳解用法

    Android BaseAdapter適配器詳解用法

    BaseAdapter是最基礎(chǔ)的Adapter類,也是最實(shí)用最常用的一個(gè)類,但是相比于ArrayAdapter之類的,對初學(xué)者來說卻比較難理解。所以本篇文章在這里介紹一下BaseAdapter
    2021-10-10

最新評論