色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

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

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
相關文章:
主站蜘蛛池模板: 日韩www视频 | 欧美色视频日本片免费高清 | 完整日本特级毛片 | 国产91精品在线 | 欧美成人手机视频免费播放 | 毛片网站在线 | 日韩欧美一二区 | 久久精品国产精品青草不卡 | 亚洲小视频在线播放 | 国产成人久久777777 | 全部孕妇毛片丰满孕妇孕交 | 欧美日本韩国一区二区 | 国产精品自拍视频 | 成人免费的性色视频 | 亚洲一区二区三区成人 | 免费a级毛片无码 | 特级淫片国产免费高清视频 | 日本高清色本免费现在观看 | 亚洲视频免费在线观看 | 国产三级国产精品国产普男人 | 美国特级毛片 | 久久精品国产精品亚洲毛片 | 久久黄网站| 9191久久久久视频 | 欧美视频亚洲视频 | 亚洲手机在线观看 | 亚洲成a人片在线观看 欧美 | 亚洲综合久久久久久中文字幕 | 毛片在线播放a | 好吊操这里只有精品 | 韩国一区在线 | 亚洲激情视频网 | 加勒比一本大道香蕉在线视频 | 久久久久免费精品国产 | 在线日韩欧美一区二区三区 | 国产亚洲精品日韩已满十八 | 免费福利在线看黄网站 | 三级网站在线免费观看 | 日韩美女一区 | 国产成人av在线 | 在线综合+亚洲+欧美中文字幕 |