zoukankan      html  css  js  c++  java
  • TabActivity

    tabActivity继承自Activity,其内部定义好了TabHost,可以通过getTabHost()获取。
    TabHost 包含了两种子元素:一些可以自由选择的Tab 和tab对应的内容tabContentto,在Layout的<TabHost>下它们分别对应 TabWidget和FrameLayout。
    <TabWidger>对应Tab。<FrameLayout>则用于包含Tab需要展示的内容。需要注意的是<TabWidger> 和<FrameLayout>的Id 必须使用系统id,分别为android:id/tabs 和 android:id/tabcontent 。因为系统会使用者两个id来初始化TabHost的两个实例变量(mTabWidget 和 mTabContent)。
     
    一般的TabActivity
    <?xml version="1.0" encoding="utf-8"?>
    <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id
    ="@android:id/tabhost" android:layout_width="fill_parent"
    android:layout_height
    ="fill_parent">
    <LinearLayout android:orientation="vertical"
    android:layout_width
    ="fill_parent" android:layout_height="fill_parent">
    <TabWidget android:id="@android:id/tabs"
    android:layout_width
    ="fill_parent" android:layout_height="wrap_content"/>
    <FrameLayout android:id="@android:id/tabcontent"
    android:layout_width
    ="fill_parent" android:layout_height="fill_parent">
    <!--省略部分代码-->
    <TextView android:id="@+id/no_team_meetings"
    android:textSize
    ="18sp" android:layout_width="fill_parent"
    android:layout_height
    ="fill_parent"/>
    <TextView android:id="@+id/no_team_meeting_stats"
    android:textSize
    ="18sp" android:layout_width="fill_parent"
    android:layout_height
    ="fill_parent"/>
    </FrameLayout>
    </LinearLayout>
    </TabHost>
     
    代码部分:
    privatevoid createTabs() {
    TabHost tabhost
    =getTabHost();
    tabhost.addTab(tabhost.newTabSpec(
    "stats_tab").
    setIndicator(
    this.getString(R.string.stats)).
    setContent(createMeetingDetails(team)));

    tabhost.addTab(tabhost.newTabSpec(
    "meetings_tab").
    setIndicator(
    this.getString(R.string.meetings)).
    setContent(createMeetingList()));
    getTabHost().setCurrentTab(
    0);
    }
     
     
    TabActivity将tabBar放置底部

     xml文件代码:

    <?xml version="1.0" encoding="utf-8"?>

    <TabHost xmlns:android="http://schemas.android.com/apk/res/android"

            android:id="@android:id/tabhost"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        >

            <LinearLayout

                    android:orientation="vertical"

                    android:layout_width="fill_parent"

                    android:layout_height="fill_parent"

                    >

                    <FrameLayout

                            android:id="@android:id/tabcontent"

                            android:layout_width="fill_parent"

                            android:layout_height="0dip"

                            android:layout_weight="1"

                            />

                    <TabWidget

                            android:id="@android:id/tabs"

                            android:layout_width="fill_parent"

                            android:layout_height="wrap_content"

                            android:layout_weight="0"

                            android:background="#ff000000"

                            />

            </LinearLayout>

    </TabHost>

  • 相关阅读:
    多个相同结构的表的字段的修改、添加
    SQL SERVER 查询去重 PARTITION BY
    message from server: "Host 'xxx' is not allowed to connect to th
    jdk 1.8 连接数据库
    恢复SQLServer数据库后,如何同步登陆名和用户名
    无法识别的属性“targetFramework”。请注意属性名称区分大小写。错误解决办法
    jquery.tablesorter 使用
    MD5加密
    C# 判断是否是节假日
    word ladder
  • 原文地址:https://www.cnblogs.com/lyz459/p/2571042.html
Copyright © 2011-2022 走看看