av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

Android TabHost如何實現(xiàn)頂部選項卡

瀏覽:4日期:2022-09-22 13:44:58

用TabHost 來實現(xiàn)頂部選項卡,上代碼:activity_main.xml

<?xml version='1.0' encoding='utf-8'?><android.support.constraint.ConstraintLayout xmlns:android='http://schemas.android.com/apk/res/android' xmlns:app='http://schemas.android.com/apk/res-auto' xmlns:tools='http://schemas.android.com/tools' android:layout_width='match_parent' android:layout_height='match_parent' tools:context='.MainActivity'> <TabHost android: android:layout_width='match_parent' android:layout_height='0dp'> <LinearLayout android:layout_width='match_parent' android:layout_height='match_parent' android:orientation='vertical'> <TabWidgetandroid: android:layout_width='match_parent'android:layout_height='wrap_content' /> <FrameLayoutandroid: android:layout_width='match_parent'android:layout_height='match_parent'><LinearLayout android: android:layout_width='match_parent' android:layout_height='match_parent' android:orientation='vertical'></LinearLayout><LinearLayout android: android:layout_width='match_parent' android:layout_height='match_parent' android:orientation='vertical'></LinearLayout><LinearLayout android: android:layout_width='match_parent' android:layout_height='match_parent' android:orientation='vertical'></LinearLayout> </FrameLayout> </LinearLayout> </TabHost></android.support.constraint.ConstraintLayout>

主方法MainActivity.java

package action.sun.com.tabhost;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.util.Log;import android.widget.TabHost;public class MainActivity extends AppCompatActivity { private TabHost tabhost; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //得到TabHost對象實例 tabhost =(TabHost) findViewById(R.id.tabMenu); //調(diào)用 TabHost.setup() tabhost.setup(); //創(chuàng)建Tab標(biāo)簽 tabhost.addTab(tabhost.newTabSpec('one').setIndicator('紅色').setContent(R.id.tab1)); tabhost.addTab(tabhost.newTabSpec('two').setIndicator('黃色').setContent(R.id.tab2)); tabhost.addTab(tabhost.newTabSpec('three').setIndicator('黃色').setContent(R.id.tab3)); tabhost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String s) {Log.d('xxx', 'onTabChanged: ='+s);if (s.equals('one')){ //可是讓viewpage的視圖顯示出來 //viewPager.setCurrentItem(0);}else if (s.equals('two')){ ////可是讓viewpage的視圖顯示出來 // viewPager.setCurrentItem(1);} } }); }}

實現(xiàn)效果

Android TabHost如何實現(xiàn)頂部選項卡

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Android
相關(guān)文章:
主站蜘蛛池模板: 91少妇丨porny丨 | 色哥网 | 国产精品国产三级国产 | 激情网站在线观看 | 五月天激情综合网 | www.伊人| 蜜臀久久99精品久久久久久宅男 | 性一交一乱一伧老太 | 国产99在线| 国产午夜精品久久久久久久 | 国产成人综合视频 | 日韩免费三级 | 美日韩一区二区 | 黄色a一级片| 日韩精品国产一区 | 久久久久人 | 久久综合激情 | 成人黄色一级片 | 日本欧美久久久久免费播放网 | 国产成人精品一区二区三区在线观看 | 综合五月 | 欧美大片91 | 国产美女精品视频 | 欧美日韩综合 | 国产在线免费 | 在线观看日韩欧美 | 国产日韩综合 | 日韩视频一区二区三区 | 特黄老太婆aa毛毛片 | 久久手机免费视频 | 久久久天堂 | 亚洲欧洲视频 | 欧美xx孕妇 | 手机看片国产 | 黄色小视频在线观看 | 国产美女永久免费无遮挡 | 国产一区在线播放 | 免费特级毛片 | 成人欧美一区二区三区黑人免费 | 成人在线视频免费观看 | 成人网战 |