国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-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
相關文章:
主站蜘蛛池模板: 国产精品免费一区二区三区 | 欧美激情国产一区在线不卡 | 欧美一级专区免费大片野外交 | 国产三级香港三韩国三级 | 午夜免费片在线观看不卡 | 99在线视频免费观看 | 亚洲欧美日韩色 | 久草精彩视频 | 夜色爽爽| 久久美女精品国产精品亚洲 | 美女亚洲综合 | 欧美一区亚洲 | 色妇女影院| 国产手机在线小视频免费观看 | 自拍偷拍欧美视频 | 丰满寡妇一级毛片 | 女人把腿劈开让男人桶的网站 | 日本护士一级毛片在线播放 | 9cao视频精品 | 国产精品久久久久久亚洲伦理 | 久久精品中文字幕首页 | 亚洲图片一区二区 | 欧美一区二区三区视视频 | 国产欧美日韩在线人成aaaa | 9l国产精品久久久久麻豆 | 国产午夜免费不卡精品理论片 | 久久久91精品国产一区二区 | 欧美一级毛片片免费孕妇 | 欧美一级毛片免费高清aa | 日韩中文字幕在线观看 | 久久综合九色综合欧洲色 | 久久三级毛片 | 欧美日韩一区二区不卡三区 | 91国语精品自产拍在线观看一 | 欧美一级特黄视频 | 国产欧美日韩一区 | 亚洲男人网 | 黄色aaaa| 亚洲欧美日韩精品久久亚洲区色播 | 亚洲福利视频精选在线视频 | www一级片|