javascriptnull 2015-09-24 04:12 采纳率: 75%
浏览 1507
已采纳

tabhost与标题文件布局问题

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上面,该怎么解决,求大神指导!

  • 写回答

3条回答 默认 最新

  • javascriptnull 2015-10-09 14:39
    关注

    已经解决了,是动态加载布局的问题

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?