午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Android TabHost如何實(shí)現(xiàn)頂部選項(xiàng)卡

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

用TabHost 來(lái)實(shí)現(xiàn)頂部選項(xiàng)卡,上代碼: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對(duì)象實(shí)例 tabhost =(TabHost) findViewById(R.id.tabMenu); //調(diào)用 TabHost.setup() tabhost.setup(); //創(chuàng)建Tab標(biāo)簽 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的視圖顯示出來(lái) //viewPager.setCurrentItem(0);}else if (s.equals('two')){ ////可是讓viewpage的視圖顯示出來(lái) // viewPager.setCurrentItem(1);} } }); }}

實(shí)現(xiàn)效果

Android TabHost如何實(shí)現(xiàn)頂部選項(xiàng)卡

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Android
相關(guān)文章:
主站蜘蛛池模板: 毛片高清| 中日韩一级片 | 韩国三级久久 | 国产极品在线播放 | 在线视频国产一区 | 欧美成人精品在线观看 | 亚洲在线日韩 | 激情丁香 | 桃色一区 | 九九视频在线观看 | 日韩精品一线二线三线 | 亚洲欧洲av | 欧美在线视频观看 | 久久人人爽人人爽人人片av高清 | 久久免费在线观看视频 | 69精品久久久 | 久久国产高清 | 欧美区在线观看 | 初体验3在线观看 | 美女在线播放 | 黄色片网站视频 | 欧美另类一区 | 四虎影视在线观看 | 国内精品一区二区 | 欧美性高潮视频 | 午夜精品免费观看 | 一级片视频播放 | 成年人网站在线观看视频 | 四虎在线精品 | 久久久久www| 免费av在线网站 | 2019国产在线 | 日韩av资源| 欧美另类专区 | 97超碰资源站| 日韩一区2区 | 91九色在线观看 | 成人激情视频在线观看 | 成人一区二区视频 | 欧美成人一区二区三区 | 国产精品久久一区 |