0

最初のレイアウトには edittext とボタンがあり、2 つ目のレイアウトには 2 つのリストビューがあり、最初のレイアウトは表示されず、アプリケーションの実行時に例外が発生しました。

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

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/etRestaurantSearchName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:hint="Enter name"
            android:inputType="text"
            android:textSize="15dip" />

        <Button
            android:id="@+id/bRestaurantSearchButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Search" />
    </LinearLayout>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ListView
            android:id="@+id/lvRestaurants"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ffffff"
            android:fillViewport="true" >
        </ListView>

        <ListView
            android:id="@+id/lvAlphabets"
            android:layout_width="40dp"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:background="@drawable/foods_alphabets_bg"
            android:orientation="vertical" >
        </ListView>

    </LinearLayout>

</RelativeLayout>

高さ、幅、または重量についての何かだと確信しています。

4

2 に答える 2

1

これを試して:

訂正:レイアウト2のandroid:layout_below="@+id/Layout1"。およびいくつかの重量関連の変更。

<LinearLayout
    android:id="@+id/Layout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <EditText
        android:id="@+id/etRestaurantSearchName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:hint="Enter name"
        android:inputType="text"
        android:textSize="15dip" />

    <Button
        android:id="@+id/bRestaurantSearchButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Search" />
</LinearLayout>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/Layout1"
    android:orientation="horizontal" >

    <ListView
        android:id="@+id/lvRestaurants"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@drawable/edit_text"
        android:fillViewport="true" >
    </ListView>

    <ListView
        android:id="@+id/lvAlphabets"
        android:layout_width="40dp"
        android:layout_height="match_parent"
        android:background="@drawable/btn_bg_pressed"
        android:orientation="vertical" >
    </ListView>
</LinearLayout>

于 2013-01-22T12:20:21.317 に答える
1

内側の 2 つのレイアウトの親レイアウトとして RelativeLayout を使用しました。したがって、2 番目の内側の Linear Layout は最初の線形レイアウトと重なるため、最初の線形レイアウトは表示されません。親レイアウトとして線形レイアウトを利用する

于 2013-01-22T12:12:39.210 に答える