18高级控件

来源:互联网 发布:core java第十版中文 编辑:程序博客网 时间:2024/05/16 05:06


a、TabHost
//*.xml

<TabHost
 android:id="@android:id/tabhost"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 xmlns:android="http://schemas.android.com/apk/res/android">
   
    <LinearLayout
        android:orientation="vertical"
        android:id="@+id/ll_main_tab"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
       
        <TabWidget
            android:id="@android:id/tabs"
            android:background="@drawable/ic_launcher"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
           
        <FrameLayout
            android:gravity="center"
            android:id="@android:id/tabcontent"
            android:fadingEdge="none"
            android:fadingEdgeLength="0.0dip"
            android:layout_width="fill_parent"
            android:layout_height="0.0dip"
            android:layout_weight="1.0">
        </FrameLayout> 
    </LinearLayout>
</TabHost>

//*Activity.java

package hy.com;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;

public class *Activity extends TabActivity { 
    private TabHost tabHost;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.*);

        tabHost = this.getTabHost();
 
        tabHost.addTab(tabHost.newTabSpec("three").setIndicator("c").setContent(R.id.tabFirst));

        tabHost.addTab(tabHost.newTabSpec("two").setIndicator("b").setContent(new Intent().setClass(this, test.class)));  
    
        tabHost.setCurrentTab(0);
        
    }
 
 
}

0 0
原创粉丝点击