介紹的是android的tab控制項,tab控制項可以達到分頁的效果,讓乙個螢幕的內容盡量豐富,當然也會增加開發的複雜程度,在有必要的時候再使用。android的tab控制項使用起來有點奇怪,必須包含和按照以下的順序:
tabhost控制項->tabwidget(必須命名為tabs)->framelayout(必須命名為tabcontent)。
接下來貼出本例執行的截圖:
main.xml的原始碼:
view plaincopy to clipboardprint?
<?xml version="1.0" encoding="utf-8"?>
android:layout_height="fill_parent" xmlns:android="" android:id="@android:id/tabhost1">
android:layout_height="wrap_content" android:layout_width="fill_parent">
android:paddingtop="65px" android:layout_width="fill_parent" android:layout_height="fill_parent">
<?xml version="1.0" encoding="utf-8"?>
android:layout_height="fill_parent" xmlns:android="" android:id="@android:id/tabhost1">
android:layout_height="wrap_content" android:layout_width="fill_parent">
android:paddingtop="65px" android:layout_width="fill_parent" android:layout_height="fill_parent">
程式原始碼:
view plaincopy to clipboardprint?
package com.testtab;
import android.os.bundle;
import android.view.view;
import android.widget.button;
import android.widget.edittext;
import android.widget.tabhost;
import android.widget.tabhost.tabspec;
public class testtab extends tabactivity
class clickevent implements view.onclicklistener
else if(v==btntab2)
} } }
注:android:id="@android:id/tabhost1"
語句報錯修改為:
android:id="@android:id/tabhost"
Android之控制項
1.textview文字框的使用 新建乙個專案 model 選中到android 找到你新建的專案 res 移動到layout上新建乙個.xml檔案 片段內容如下 android layout width wrap content android layout height wrap content...
Android 學習筆記之常用控制項
1 listview 是一套檢視 view 元件 component 2 listview 通常以列表的形式在 android 客戶端顯示一些列表選項 item 每個列表選項擁有同樣的布局 3 為了提公升 listview 的效能,在設計 listview 時,禁用了其 addview 方法 4 l...
控制項縮小android控制項之WebView
工作之餘抽點時間出來寫寫博文,希望對新接觸的朋友有幫助。今天在這裡和大家一起學習一下控制項縮小 發現這個控制項挺好用,能自已控制進度條,而且這個控制項的功能非常壯大,後續再另說 先上個簡單的 每日一道理 青春是用意志的血滴和拼搏的汗水釀成的瓊漿 歷久彌香 青春是用不凋的希望和不滅的嚮往編織的彩虹 絢...