亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

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

Android TabHost如何實現頂部選項卡

瀏覽:4日期: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精品波多结衣一区 | 国产伦精品一区二区三区免费迷 | 成人国产精品一级毛片天堂 | 亚洲精品综合网在线8050影院 | a级片欧美 | 黄色一级在线视频 | 亚洲欧美日韩综合久久久久 | 亚洲欧美中文日韩在线v日本 | 亚洲精品视频免费在线观看 | 黄色大片在线免费看 | 国产精品亚洲一区二区三区正片 | 日本一级毛片视频无遮挡免费 | 亚洲色图综合区 | 欧美在线一区视频 | 日韩一级大毛片欧美一级 | 午夜网站在线观看 | 二级黄绝大片中国免费视频0 | 国产亚洲欧美在线 | 亚洲综合精品成人啪啪 | 视频一二三区 | 精品国产高清a毛片 | 国产码一区二区三区 | 亚洲春色在线视频 | 欧美爱爱动态 | 一级特黄aaa大片免费看 | 欧美成人乱弄视频 | 国产又色又爽的视频免费 | 久久香蕉国产线看观看网站 | 黄色免费在线观看视频 | 黄色片中文字幕 | 国产精品爱啪在线线免费观看 | 日韩精品a在线视频 | 超级碰碰碰免费视频播放 | 久久在现 | 欧洲美女大片免费播放器视频 | 国产视频h | 嫩草免费视频 | 久久国产精品自线拍免费 | 精品视频在线免费 | 亚洲成人网在线 | 99re最新|