androidbroadcast / ViewBindingPropertyDelegate

Make work with Android View Binding simpler
https://proandroiddev.com/make-android-view-binding-great-with-kotlin-b71dd9c87719
Apache License 2.0
1.42k stars 102 forks source link

How to use in include layout #58

Closed wsdydeni closed 3 years ago

kirich1409 commented 3 years ago

No details provided

JayGajjar commented 3 years ago

        <FrameLayout
            android:id="@+id/frameLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <include layout="@layout/order_list" />
        </FrameLayout>

How can i use binding for the layout that are included in my main layout file

dev-gvs commented 3 years ago

        <FrameLayout
            android:id="@+id/frameLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <include layout="@layout/order_list" />
        </FrameLayout>

How can i use binding for the layout that are included in my main layout file

@JayGajjar, if it's generic layout, without merge, then assign id to the included layout:

<FrameLayout
            android:id="@+id/frameLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

and use it how you would use binding with any other component:

binding.order_list...
kirich1409 commented 3 years ago

The library doesn't add any code to a ViewBinding instance. For access included layout ViewBinding contains another instance of ViewBinding. That works in Android Studio 4.2