Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ItemLayoutBinding #4

Closed
CodeK1988 opened this issue Aug 10, 2016 · 3 comments
Closed

ItemLayoutBinding #4

CodeK1988 opened this issue Aug 10, 2016 · 3 comments

Comments

@CodeK1988
Copy link

can you tell me... ItemLayoutBinding? thanks!

@ahmedrizwan
Copy link
Owner

ItemLayoutBinding represents the generated Binding from the xml layout file.
For example if you have header_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="@dimen/activity_horizontal_margin">

        <TextView android:id="@+id/textViewItem"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  tools:text="Recycler Item"/>

    </LinearLayout>
</layout>

Then in code you'll be creating RxDataSource like this

RxDataSource<String> rxDataSource = new RxDataSource<>(dataSet);
//compose, bind and subscribe!
rxDataSource.<HeaderLayoutBinding>bindRecyclerView(recyclerView, R.layout.header_layout) 
      .subscribe(viewHolder -> {
        ...
      });

Make sure you have DataBinding enabled in your build.gradle file.
And also if you're project isn't resolving HeaderLayoutBinding, then click on Make Project under Build menu, then it should be resolved.

For more detailed information and examples, refer to this article.

@CodeK1988
Copy link
Author

thank you very much!
I forgot to add
dataBinding {//数据绑定
enabled = true
}

@Polyterative
Copy link

Also make sure to have you layout starting with

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

otherwise binding won't show up at all


Still mine doesn't compile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants