zoukankan      html  css  js  c++  java
  • Android学习之路十四:TabHost

      Android中的Tab选项卡,如TabHost,实现它可以继承TabActivity,当然也可以直接继承Activity。本TabActivity就是一个已经分页的Activity。

      

      案例:

      XML代码:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <TabHost
            android:id="@+id/tabHost"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:paddingTop="80px"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">
                <TextView
                    android:id="@+id/first_page"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:text="@string/first_page"/>
                <TextView
                    android:id="@+id/second_page"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:text="@string/second_page"/>
            </FrameLayout>"
        </TabHost>
    
    </LinearLayout>

       java代码:

      

    first_page = (TextView) findViewById(R.id.first_page);
            second_page = (TextView) findViewById(R.id.second_page);
            TabHost th = (TabHost) findViewById(R.id.tabHost);
            TabHost.TabSpec ts = th.newTabSpec("0");
            ts.setContent(R.id.first_page);
            ts.setIndicator(this.getString(R.id.first_page));
            th.addTab(ts);
            ts = th.newTabSpec("1");
            ts.setContent(R.id.second_page);
            ts.setIndicator(this.getString(R.id.second_page));
            th.addTab(ts);
            th.setCurrentTab(0);
  • 相关阅读:
    HDU4513 吉哥系列故事——完美队形II Manacher算法
    POJ3974 Palindrome Manacher算法
    POJ1674 Sorting by Swapping 置换群
    100个著名初等数学问题[转载]
    POJ1026 Cipher 置换群
    FOJ1977 Pandora adventure 插头DP
    HDU1964 Pipes 插头DP
    POJ1286 Necklace of Beads polya计数
    Manacher算法O(n)回文子串算法[转载]
    POJ3270 Cow Sorting 置换群
  • 原文地址:https://www.cnblogs.com/thinksasa/p/2919739.html
Copyright © 2011-2022 走看看