色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

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

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

瀏覽:3日期: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精品福利手机国产在线 | 免费观看一级欧美大 | 国产欧美一区二区三区观看 | 成人在线视频国产 | 男人天堂视频在线观看 | 欧美成人亚洲综合精品欧美激情 | 大尺度福利视频奶水在线 | 正在播放国产一区 | 午夜无遮挡怕怕怕免费视频 | 女人扒开腿让男人捅啪啪 | 狠狠色丁香婷婷久久综合不卡 | 国产精选91热在线观看 | 日韩一区国产二区欧美三区 | www亚洲成人| 窝窝女人体国产午夜视频 | 亚洲国产最新 | 国产成人午夜 | 欧美专区视频 | 国产精品美乳免费看 | 国产99在线播放 | 视频网18免费 | 欧美videofree性欧美另类 | 国产一级小视频 | 加勒比heyzo 加勒比久久综合 | 亚洲男人天堂2018 | 在线观看91精品国产入口 | 成年女人看片免费视频播放器 | 国产成人综合日韩精品婷婷九月 | 精品视频一区二区三区四区 | 免费91最新地址永久入口 | 亚洲欧美视频 | 一级做性色a爱片久久片 | 精品在线网站 | 国产一级毛片一区二区三区 | 日韩亚洲综合精品国产 | 一级做α爱过程免费视频 | 欧美日韩色黄大片在线视频 | 精品国产自在现线看久久 | 国产成人自拍在线 | 国产精品久久网 | 国产精品久久久久久小说 |