0

include タグを使用して、横向きモードで activity_main.xml と contact_details.xml のレイアウト コードを再利用しようとしました。activity_main を左側に、contact_details を右側に表示したいと思います。しかし、横向きモードに切り替えるとアプリケーションがクラッシュします。

これは activity_main.xml のコーディングです

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

<ListView
    android:id="@+id/list_data"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1" />

<Button
    android:id="@+id/btnAddContact"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dp"
    android:layout_weight="0"
    android:text="Add Contact" />

</LinearLayout>

これは、contact_details.xml のコーディングです。

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

    <ListView
        android:id="@+id/lvContactDetails"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

</LinearLayout>

これは私のlayout-land/activity_main.xmlのコーディングです

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

<include layout="@layout/activity_main"/>
<View
    android:layout_width="1dp"
    android:layout_height="fill_parent"
    android:background="#A3A3A3"/>

<include layout="@layout/contact_details"/>

</LinearLayout>

この問題を解決するためのヒントはありますか? 前もって感謝します。

4

2 に答える 2

2

提案してくれたアディニアに感謝します。これは、Activity_main.xml という同じレイアウト名をコールバックしてはならないためです。これがクラッシュの主な原因です。アディニアが述べたように、循環参照である可能性があります。再度、感謝します。ちなみに、私は2日以内に回答を受け入れることしか許されていません.

于 2013-04-01T12:49:47.067 に答える
0

使用している activity_main.xml 、contact_details.xml で

android:layout_width="fill_parent"

代わりに使用してみてください

android:layout_width="wrap_content"

logcatレポートを投稿しない場合

于 2013-04-01T12:40:49.950 に答える