【问题标题】:I cannot get this xml containing TabHost to load correctly in an android application我无法让这个包含 TabHost 的 xml 在 android 应用程序中正确加载
【发布时间】:2011-06-17 19:18:04
【问题描述】:

有谁知道为什么这不会正确加载。尝试加载此 xml 时,我在模拟器中强制退出。我正在尝试将布局设置为此 TabHost。

<?xml version="1.0" encoding="utf-8"?>
<TabHost
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:background="#FFFFFF">
  <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5dp">
    <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content"     android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="10px" android:layout_marginBottom="10px">
        <ImageView android:id="@+id/imageView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginRight="10px" android:src="@drawable/logo"></ImageView>
        <LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="wrap_content" android:layout_gravity="center">
            <TextView android:text="text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/Text1" android:textColor="#1565BC" android:textStyle="bold"></TextView>
            <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="text" android:id="@+id/Text2" android:textColor="#333333"></TextView>
            <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="text" android:id="@+id/Text3" android:textColor="#333333"></TextView>
            <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="text" android:id="@+id/Text4" android:textColor="#333333"></TextView>
            <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="text" android:id="@+id/Text5" android:textColor="#1565BC"></TextView>
        </LinearLayout>
    </TableRow>
  <TabWidget 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@android:id/tabs" android:layout_below="@+id/tableRow1" android:layout_alignLeft="@+id/tableRow1" android:layout_alignRight="@+id/tableRow1"/>
<FrameLayout
    android:id="@android:id/tabcontent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    </FrameLayout>
  </RelativeLayout>
</TabHost>

【问题讨论】:

  • 你应该发布你得到的异常。

标签: java android xml tabs android-tabhost


【解决方案1】:

我只是使用你的布局没有任何问题,我唯一改变的就是

<ImageView android:src="@drawable/mylogo"></ImageView>

检查可绘制文件夹中的条目,这可能是问题所在。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2012-12-03
  • 1970-01-01
  • 2013-10-13
  • 2018-11-20
  • 2013-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多