package com.example.trainticket;
import android.app.TabActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Window;
import android.widget.TabHost;
public class OrderDemandActivity extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.orderdemand);
// TabHost tabhost=(TabHost)findViewById(R.id.ordertabhost);
// tabhost.setup(this.getLocalActivityManager());
TabHost tabhost=getTabHost();
LayoutInflater.from(OrderDemandActivity.this).inflate(R.layout.orderdemand,tabhost.getTabContentView(),true);
tabhost.addTab(tabhost.newTabSpec("yiwanchengorder").
setIndicator(LayoutInflater.from(OrderDemandActivity.this).
inflate(R.layout.ordercompleted,null)).setContent(R.id.yiwancheng));
tabhost.addTab(tabhost.newTabSpec("noorder").
setIndicator(LayoutInflater.from(OrderDemandActivity.this).
inflate(R.layout.orderhanginthe,null)).setContent(R.id.weiwancheng));
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ECECFF"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0066CC"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:text="@string/ordertitle"
android:textColor="@android:color/white"
android:textSize="20sp" />
</LinearLayout>
<com.example.trainticket.MyScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TabHost
android:id="@+id/ordertabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TabWidget
android:id="@+id/ordertabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#C7C7E2" >
</TabWidget>
<FrameLayout
android:id="@+id/ordertabcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/yiwancheng"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:text="@string/ordertime"
android:textSize="12sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#E0E0E0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:paddingLeft="15dp"
android:paddingRight="10dp"
android:paddingTop="2dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:text="@string/ordertoday" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:background="@drawable/jshop_arrow_right" />
</FrameLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:background="#E0E0E0" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:paddingLeft="15dp"
android:paddingRight="10dp"
android:paddingTop="2dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:text="@string/nogoorder" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:background="@drawable/jshop_arrow_right" />
</FrameLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:background="#E0E0E0" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:paddingLeft="15dp"
android:paddingRight="10dp"
android:paddingTop="2dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:text="@string/oldorder" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:background="@drawable/jshop_arrow_right" />
</FrameLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#E0E0E0" />
<TextView
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#E0E0E0" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/weiwancheng"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="未完成订单(0)" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
</com.example.trainticket.MyScrollView>
</LinearLayout>
我把标题布局放在tabhost上面,结果放到模拟器上,却加载到tabhost里面去了,是不是因为,添加tabhost页面的时候我把整个布局文件,放进去的原因呢?我是想要标题在tabhost上面,该怎么解决,求大神指导!