2

別のxmlにナビゲーションバーコードxmlを含めると、次のエラーが生成されます。

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my/com.my.Login}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>

login.xmlは

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

    <include
        android:layout_height="wrap_content"
        layout="@layout/navbar" />

</LinearLayout>

navbar.xmlは

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@style/tableRowStyle"
    android:orientation="horizontal"
    android:paddingRight="0dp" >

    <Button
        android:id="@+id/button2"
        android:layout_width="52dp"
        android:layout_height="48dp"
        android:background="@drawable/home" />

    <View
        android:layout_width="1px"
        android:layout_height="fill_parent"
        android:background="#1f1f1f" />

    <View
        android:layout_width="1px"
        android:layout_height="fill_parent"
        android:background="#454545" />

    <Button
        android:id="@+id/button1"
        android:layout_width="190dp"
        android:layout_height="48dp"
        android:layout_weight="0.35"
        android:background="@drawable/stock" />

    <View
        android:layout_width="1px"
        android:layout_height="fill_parent"
        android:background="#1f1f1f" />

    <View
        android:layout_width="1px"
        android:layout_height="fill_parent"
        android:background="#454545" />

    <Button
        android:id="@+id/button2"
        android:layout_width="52dp"
        android:layout_height="48dp"
        android:background="@drawable/home" />

</LinearLayout>

その背後にある問題は何ですか?

4

4 に答える 4

1

それでしょうか

<include
    android:layout_height="wrap_content"
    layout="@layout/navbar" />

する必要があります

<include
    android:layout_height="wrap_content"
    android:layout="@layout/navbar" />
于 2012-12-10T06:54:11.287 に答える
1

java.lang.RuntimeException:アクティビティを開始できませんComponentInfo {com.my/com.my.Login}:android.view.InflateException:バイナリXMLファイルの行#1:クラスの拡張エラー

このエラーが発生した場合は、setContentView(R.id.xml_file);のレイアウトの呼び出しが一致していないことを意味します。したがって、最初に、JavaコードでレイアウトIDを正しく呼び出しているかどうかを確認してください。

そして、xmlからstyle = "@ style/tableStyle"を削除するだけです。うまくいくと思います。

于 2012-12-10T07:04:49.630 に答える
0

レイアウト幅も指定します。

<include
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    layout="@layout/navbar" />
于 2012-12-10T06:50:19.160 に答える
0

削除されましたandroid:background="@style/tableRowStyle"

今では正常に動作しています。貴重なご回答ありがとうございました:)

于 2012-12-10T07:02:00.487 に答える