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

您的位置:首頁技術文章
文章詳情頁

Android TabHost如何實現頂部選項卡

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

用TabHost 來實現頂部選項卡,上代碼: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); //調用 TabHost.setup() tabhost.setup(); //創建Tab標簽 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);} } }); }}

實現效果

Android TabHost如何實現頂部選項卡

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Android
相關文章:
主站蜘蛛池模板: 天天操天天天干 | 91视频88av| 日韩av一区二区在线观看 | 91视频国产一区 | 天天干天天爱天天操 | 激情六月丁香 | 女女百合av大片一区二区三区九县 | 日本视频在线播放 | 日韩中文字幕网 | 7777精品伊人久久精品影视 | 国产伦精品一区二区三区照片91 | 中文字幕亚洲专区 | 99国内精品久久久久久久 | 不卡一区 | 99亚洲精品| 亚洲巨乳自拍在线视频 | 国产97在线看| 国产精品99视频 | 国产精品久久久久免费 | 亚洲人成人一区二区在线观看 | 午夜在线视频一区二区三区 | 老牛嫩草一区二区三区av | 欧美一区二区三区的 | 午夜在线影院 | 久在线 | 成人午夜视频在线观看 | 亚洲性视频 | 欧美男人天堂 | 97碰碰碰 | 亚洲精品一区二区三区蜜桃久 | 国产在线视频一区二区 | 免费a v网站| 成人精品国产免费网站 | 国产一区二区三区久久 | 久久91精品久久久久久9鸭 | 欧美一区视频 | 中文字幕一区二区三区四区不卡 | 久综合 | 日韩三极| 久久综合一区 | 国产免费av在线 |