package com.example.test13_tabhost;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.widget.TabHost;import android.widget.TabHost.TabSpec;import android.widget.TextView;public class MainActivity extends Activity {private TabHost tabhost;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);tabhost = (TabHost) findViewById(R.id.tabhost);tabhost.setup();//找到TabWidget和FraeLayout//添加標(biāo)簽頁TabSpec tab1 = tabhost.newTabSpec("tab1");// //指定標(biāo)簽// tab1.setIndicator("精選",getResources().getDrawable(R.drawable.a));//指定標(biāo)簽頁的內(nèi)容tab1.setIndicator(createView("精選"));tab1.setContent(R.id.line1);tabhost.addTab(tab1);TabSpec tab2 = tabhost.newTabSpec("tab2");// tab2.setIndicator("第二頁",getResources().getDrawable(R.drawable.a));tab2.setIndicator(createView("第二頁"));tab2.setContent(R.id.line2);tabhost.addTab(tab2);TabSpec tab3 = tabhost.newTabSpec("tab3");// tab3.setIndicator("第三頁",getResources().getDrawable(R.drawable.a));tab3.setIndicator(createView("第三頁"));tab3.setContent(R.id.line3);tabhost.addTab(tab3);}private View createView(String text){View view = View.inflate(this, R.layout.tab, null);TextView tv_title = (TextView) view.findViewById(R.id.tv_title);tv_title.setText(text);return view;} ?android:drawable="@drawable/o">android:id="@+id/tabhost"android:layout_width="match_parent"android:layout_height="match_parent" >android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" >android:id="@android:id/tabs"android:layout_width="match_parent"android:id="@android:id/tacontent"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1" android:id="@+id/line1"android:layout_width="match_parent"android:layout_height="match_parent" >android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center"android:text="精選"android:textSize="30sp" />android:id="@+id/line2"android:layout_width="match_parent"android:layout_height="match_parent" >android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center"android:text="第二頁"android:textSize="30sp"/>android:id="@+id/line3"android:layout_width="match_parent"android:layout_height="match_parent" >android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center"android:text="第三頁"android:textSize="30sp"/>android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:background="@drawable/bg">android:id="@+id/tv_title"android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center"android:text="首頁"android:textColor="@android:color/white"android:textSize="22sp"/>
TabHost
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門庐船,熙熙樓的掌柜王于貴愁眉苦臉地迎上來银酬,“玉大人,你說我怎么就攤上這事筐钟】桑” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵盗棵,是天一觀的道長壮韭。 經(jīng)常有香客問我北发,道長,這世上最難降的妖魔是什么喷屋? 我笑而不...
- 正文 為了忘掉前任琳拨,我火速辦了婚禮,結(jié)果婚禮上屯曹,老公的妹妹穿的比我還像新娘狱庇。我一直安慰自己,他們只是感情好恶耽,可當(dāng)我...
- 文/花漫 我一把揭開白布密任。 她就那樣靜靜地躺著,像睡著了一般偷俭。 火紅的嫁衣襯著肌膚如雪浪讳。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼辐真,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了崖堤?” 一聲冷哼從身側(cè)響起侍咱,我...
- 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎倘感,沒想到半個(gè)月后放坏,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡老玛,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年淤年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片蜡豹。...
- 正文 年R本政府宣布,位于F島的核電站齐遵,受9級(jí)特大地震影響寂玲,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜梗摇,卻給世界環(huán)境...
- 文/蒙蒙 一拓哟、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧伶授,春花似錦断序、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至疮蹦,卻和暖如春诸迟,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背愕乎。 一陣腳步聲響...
- 正文 我出身青樓,卻偏偏與公主長得像贮尖,于是被迫代替她去往敵國和親笛粘。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 一 . 自定義標(biāo)簽二 . ViewPager三. ScrollView ----------------效果圖--...
- 先說一下這篇文章里面的內(nèi)容:TCP 客戶端, 自定義對(duì)話框, 自定義按鈕, ProgressBar豎直顯示, 重力...
- 很多朋友會(huì)遇見這么一個(gè)問題湿硝,項(xiàng)目寫完了薪前,需要新建一個(gè)項(xiàng)目,或者剛開始做項(xiàng)目关斜,就會(huì)發(fā)現(xiàn)示括,整體框架怎么搭建,大多數(shù)都是...
- 一痢畜、Welcome延時(shí)跳轉(zhuǎn)界面(1s跳轉(zhuǎn)) 二垛膝、登陸界面(調(diào)用數(shù)據(jù)庫) 輸入用戶名、密碼丁稀,點(diǎn)擊注冊(cè)吼拥,出現(xiàn)Toast...