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

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

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

瀏覽:5日期: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)文章:
主站蜘蛛池模板: 亚洲精品一区二三区不卡 | 亚洲aⅴ一区二区 | 免费一区二区三区 | 欧美一区二区视频 | 91爱爱·com| 亚洲欧美日韩国产 | 中文字幕久久精品 | 午夜影院 | 国产精品永久免费 | 99久久精品国产一区二区三区 | 午夜99 | 日本免费一区二区三区 | 午夜爽爽爽男女免费观看影院 | 337p日韩| 国产高清在线观看 | 日操操| 国产精品久久久久久久久久免费 | 日本免费视频在线观看 | 欧美日韩一区二区三区四区 | h肉视频| www.国产精 | 日韩福利在线 | 欧美日韩一区在线观看 | 亚洲精久 | 国产成人精品久久 | 二区不卡 | 亚洲精品国产一区 | 超碰3| 久久久www成人免费无遮挡大片 | 亚洲一区二区精品视频 | 久久一区二区三区四区五区 | 亚洲va在线va天堂va狼色在线 | 欧美a级成人淫片免费看 | 色婷婷精品 | 亚欧洲精品在线视频免费观看 | 久久久久国产一区二区三区四区 | 日本不卡一区二区三区在线观看 | 久久99精品国产麻豆婷婷 | 红桃成人在线 | 密色视频| 久久性色 |