graphical layout界面和模拟器界面不一致

张亚星 发布于 2014/11/04 11:02
阅读 1K+
收藏 0
<?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/textview1"  
                android:layout_width="fill_parent"  
                android:layout_height="fill_parent"  
                android:text="编辑" />  
            <TextView  
                android:id="@+id/textview2"  
                android:layout_width="fill_parent"  
                android:layout_height="fill_parent"  
                android:text="分组" />  
            <TextView  
                android:id="@+id/textview3"  
                android:layout_width="fill_parent"  
                android:layout_height="fill_parent"  
                android:text="全部" />  
            <TextView  
                android:id="@+id/textview4"  
                android:layout_width="fill_parent"  
                android:layout_height="fill_parent"  
                android:text="添加" />  
        </FrameLayout>  
    </LinearLayout>  
</TabHost>



public class FriendList extends TabActivity {
    @Override
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.friendlist);
		//获取资源句柄
        Resources res = getResources();
        //获取TabHost
        TabHost myTabHost = getTabHost();
        //添加第1个选项页面
        TabSpec spec = myTabHost.newTabSpec("编辑").setIndicator("编辑", res.getDrawable(android.R.drawable.sym_call_incoming)).setContent(R.id.textview1);
        myTabHost.addTab(spec);
        //添加第2个选项页面
        spec = myTabHost.newTabSpec("分组").setIndicator("分组", res.getDrawable(android.R.drawable.sym_call_incoming)).setContent(R.id.textview2);
        myTabHost.addTab(spec);
        //添加第3个选项页面
        spec = myTabHost.newTabSpec("全部").setIndicator("全部", res.getDrawable(android.R.drawable.sym_call_incoming)).setContent(R.id.textview3);
        myTabHost.addTab(spec);
        //添加第4个选项页面
        spec = myTabHost.newTabSpec("添加").setIndicator("添加", res.getDrawable(android.R.drawable.sym_call_incoming)).setContent(R.id.textview4);
        myTabHost.addTab(spec);
	}
}



加载中
返回顶部
顶部