代码之家  ›  专栏  ›  技术社区  ›  Melody Horn

XML layout not cooperating

  •  1
  • Melody Horn  · 技术社区  · 16 年前

    I'm having trouble trying to use a list in my activity. My XML for res/layout/main.xml is as follows:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        />
    <ListView android:id="@+id/ListView01" android:layout_width="wrap_content" android:layout_height="wrap_content">
    <TwoLineListItem android:id="@+id/TwoLineListItem01" android:layout_width="wrap_content" android:layout_height="wrap_content">
    <TextView android:id="@android:id/text1"
            android:layout_marginTop="1dip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="15sp"
            android:textStyle="bold"
            android:text="@string/text1" />
    <TextView android:id="@android:id/text2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@android:id/text1"
            android:layout_alignLeft="@android:id/text1"
            android:paddingBottom="4dip"
            android:includeFontPadding="false"
            android:textSize="15sp"
            android:textStyle="normal"
            android:text="@string/text2" />
    </TwoLineListItem>
    </ListView>
    </LinearLayout>
    

    Once I try to run it, however, my app just "quits unexpectedly". It's got to be something wrong with the XML, since the activity is just the default setContentView(R.layout.main); Please tell me what I'm doing wrong.

    1 回复  |  直到 16 年前
        1
  •  2
  •   Macarse    16 年前

    TwoLineListItem 看起来用错了。

    检查这个 tutorial