In my XML editor on Eclipse I see the tabhost, and it looks exactly how I want it, but when I run it I don't see the tabHost at all, how can I make sure it's visable?

在Eclipse上的XML编辑器中,我看到tabhost,它看起来就像我想要的那样,但是当我运行它时,我根本看不到tabHost,我怎样才能确保它是可见的?

This is my XML. Again, the editor shows it, but when I run it it doesn't, the activity which inflates it doesn't do much yet, just change the two textfields. Any ideas?

这是我的XML。再次,编辑器显示它,但是当我运行它时它没有,膨胀它的活动还没有做太多,只需更改两个文本字段。有任何想法吗?

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnCount="2"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/name"
        android:layout_width="238dp"
        android:layout_column="0"
        android:layout_columnSpan="2"
        android:layout_gravity="top|left"
        android:layout_marginTop="7dp"
        android:layout_marginLeft="3dp"
        android:layout_row="0"
        android:gravity="top"
        android:maxLines="1"
        android:padding="3dp"
        android:text="Motherfucking Acer Laptop X314134"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <View
        android:layout_height="2dp"
        android:layout_width="fill_parent"
        android:layout_row="1"
        android:layout_column="0"
        android:layout_columnSpan="2"
        android:background="#FF000000"
        />

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_column="0"
        android:layout_columnSpan="2"
        android:layout_gravity="center_horizontal"
        android:layout_row="2" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <LinearLayout
                    android:id="@+id/Info"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/Specs"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/Fotos"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/Prijzen"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>

    <TextView
        android:id="@+id/score"
        android:layout_column="1"
        android:layout_marginRight="3dp"
        android:layout_marginTop="4dp"
        android:layout_gravity="right"
        android:layout_row="0"
        android:gravity="center_vertical"
        android:padding="3dp"
        android:text="100%"
        android:textSize="24sp" />

    <Space
        android:id="@+id/space2"
        android:layout_width="1dp"
        android:layout_height="40dp"
        android:layout_column="0"
        android:layout_gravity="left"
        android:layout_row="0" />

    <Space
        android:id="@+id/space1"
        android:layout_width="1dp"
        android:layout_height="415dp"
        android:layout_column="0"
        android:layout_gravity="left"
        android:layout_row="2" />

</GridLayout>

2 个解决方案

#1


7

You have to do this programmatically, for example:

您必须以编程方式执行此操作,例如:

 tabhost = (TabHost) findViewById(android.R.id.tabhost);
    tabhost.setup();
    TabSpec ts = tabhost.newTabSpec("tag1"); 
    ts.setContent(R.id.tab1);
    ts.setIndicator("First Tab");
    tabhost.addTab(ts);

    ts = tabhost.newTabSpec("tag2"); 
    ts.setContent(R.id.tab2);
    ts.setIndicator("Second Tab");  
    tabhost.addTab(ts);
    ts= tabhost.newTabSpec("tag3");
    ts.setContent(R.id.tab3);
    ts.setIndicator("Third Tab");
    tabhost.addTab(ts);

更多相关文章

  1. Javassist生成class(生成类,方法,字段,注解)
  2. Play 2.0生成隐藏字段而不使用div包装器
  3. JAVAWEB网站开发,一对多,多对一,主表与子表(主外键)相连接,会导致主表
  4. 根据用户的动态字段对链接列表进行排序
  5. MongoDB中的按组计算的字段

随机推荐

  1. 单击内部标记时将类添加到li
  2. 在JavaScript中的for循环中调用异步函数
  3. 你如何组织Javascript verboseness?
  4. 优雅降级对非JavaScript ui的重要性
  5. ajax请求返回一个空字符串作为响应
  6. 重写Regex以用于比较吗?
  7. javascript省份证验证
  8. 第三节(JavaScript 对象、日期,函数)
  9. 在父div中以编程方式滚动一组div
  10. javascript基本知识点梳理总结