TabHost layout and DataBinding

Viewed 361

I read about android data binding and want to use it in my application, but I failed on xml layout stage.

I have activity_main.xml like this:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
</data>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:id="@+id/tab1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

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

        </LinearLayout>

    </FrameLayout>
</LinearLayout>
</TabHost>
</layout>

and tab1.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<EditText
...

I want apply data binding to the last EditText, but if I insert

<layout xmlns:android="http://schemas.android.com/apk/res/android">
   <data>
   </data>
   <TabHost>
   ...

this causes

activity_main.xml:9: AAPT: Error parsing XML: duplicate attribute

The question is, how should I combind data binding and TabHost to bind EditText in included layout?

Here is repo with code from question

3 Answers
Related