Databinding-Fehler: Nur ein layout-element Daten-element erlaubt sind.

Ich bekomme folgenden Fehler bei der Verwendung von databinding und beinhalten die tag-innen:

Error:Execution failed for task ':app:dataBindingProcessLayoutsBetaDebug'.>data binding error msg:Only one layout element and one data element are allowed. [path to file] has 3file:[path to file]****\ data binding error ****

Dies ist mein layout-Datei:

[...]

        <LinearLayout
            android:id="@+id/activity_description_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:orientation="vertical">

            <include
                android:id="@+id/activity_description_header_bottom"
                layout="@layout/activity_description_header_bottom" />

            <include
                android:id="@+id/activity_description_contact_info"
                layout="@layout/activity_description_contact_info" />

            <include
                android:id="@+id/activity_description_other_info_box"
                layout="@layout/activity_description_other_info_box" />

            <include
                android:id="@+id/activity_description_bottom_buttons"
                layout="@layout/activity_description_bottom_buttons" />
        </LinearLayout>
[...]
</layout>

Und in jedem der enthaltenen layouts, ich habe so etwas wie dieses:

<layout xmlns:android="http://schemas.android.com/apk/res/android">
[...]
</layout>

Aus dieser Antwort: Android-Datenbindung mittels include-tag ich nehme an, dass mein code korrekt ist, warum databinder denkt, dass ich mehr als single-tag in der Datei?

  • Aus dem Stegreif würde es scheinen, dass <include> kann nur integrieren Sie widgets (ggf. mit Datenbindung Ausdrücke) als klassische layout-Ressourcen. Alle <layout> und <data> Elemente werden in der top-level-Ressource, die mit dem <include> Elemente. Wäre das nicht eine überraschende Einschränkung IMHO, aber es wäre etwas enttäuschend.
InformationsquelleAutor RMK | 2016-04-09
Schreibe einen Kommentar