色综合图-色综合图片-色综合图片二区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)文章:
主站蜘蛛池模板: 久久影视一区 | 国产精品一区高清在线观看 | 色三级大全高清视频在线观看 | 寡妇野外啪啪一区二区 | 欧美67194| 国产成人精品免费视 | 国产精品久久久久毛片 | a级男女性高爱潮高清试 | 亚洲欧美日产综合在线看 | 国产精品黄网站免费观看 | 伊人色综合久久成人 | 精品一区二区三区五区六区 | 欧洲做人爱c欧美 | 成人免费网站在线观看 | 日本免费一区尤物 | 国产精品91在线播放 | 97婷婷狠狠成人免费视频 | 日韩在线成人 | 欧美日韩中文国产一区二区三区 | 国产一级毛片亚洲久留木玲 | 亚洲激情 欧美 | 欧美三级日韩 | 欧美操操操 | 久久日本精品一区二区免费 | 欧美成人全部费免网站 | 免费看香港一级毛片 | 日韩高清免费观看 | 黄色美女视频 | 女人张开双腿让男人桶爽免 | 目韩一区二区三区系列片丶 | 欧美色另类 | 国产爽爽视频 | 久久这里只有精品视频99 | 美女张开双腿让男人桶 | 国产在线视频一区 | 国产美女作爱 | 亚洲成a人片在线观看精品 亚洲成a人片在线观看中 | 日韩欧美~中文字幕 | 成人小视频在线播放 | 久久亚洲精品成人综合 | 欧美亚洲另类久久综合 |