国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

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

Android TabHost如何實現頂部選項卡

瀏覽:3日期: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
相關文章:
主站蜘蛛池模板: 92精品国产成人观看免费 | 亚洲手机在线 | 久草高清视频 | 在线观看国内自拍 | 国产大臿蕉香蕉大视频女 | 日韩欧美综合 | 国产精品高清一区二区 | 国产乱淫a∨片免费视频 | 国内精品a | 国产欧美日韩精品第二区 | 国产日韩久久久精品影院首页 | 手机看成人片 | 午夜精品影院 | av片免费大全在线观看不卡 | 国产aⅴ精品一区二区三区久久 | 高清不卡毛片免费观看 | 国产成人综合亚洲 | 国产精品2020观看久久 | 中文字幕在线视频网站 | 欧美在线亚洲国产免m观看 欧美在线一级精品 | 亚洲3p| 国产一级淫片a免费播放口之 | 亚洲加勒比久久88色综合 | 国产精品v一区二区三区 | 国产精品欧美日韩 | 亚洲第一男人天堂 | 亚洲精品一区二区三区www | 国产午夜精品久久久久免费视 | 成人毛片免费网站 | 欧美一级毛片特黄黄 | 亚洲一区二区三区在线网站 | 欧美日韩另类综合 | 日韩在线小视频 | 在线看亚洲 | 美美女高清毛片视频黄的一免费 | 一本三道a无线码一区v小说 | 一区二区中文字幕亚洲精品 | 国产午夜亚洲精品一区网站 | 久久精品在线免费观看 | 99在线视频网站 | 国产视频三级 |