I am building an Android application in which I am using Data binding library. I am little new to Data binding concept and looking for the solution for the following
There is a layout file called otp_validation.xml
<data>
<variable
name="otpViewModel"
type="dial.to.go.otp.OTPViewModel" />
</data>
<ConstraintLayout
.....................
.....................
.....................
<LinearLayout
android:id="@+id/otp_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_20sdp"
android:orientation="horizontal"
android:weightSum="4">
<androidx.appcompat.widget.AppCompatEditText
android:layout_width="@dimen/_40sdp"
android:layout_height="@dimen/_50sdp"
android:layout_weight="1"
android:background="@drawable/all_edit_selector"
android:gravity="center"
android:inputType="number"
android:maxLength="1"
android:textSize="@dimen/_22sdp" />
<androidx.appcompat.widget.AppCompatEditText
android:layout_width="@dimen/_40sdp"
android:layout_height="@dimen/_50sdp"
android:layout_marginLeft="@dimen/_8sdp"
android:layout_weight="1"
android:background="@drawable/all_edit_selector"
android:gravity="center"
android:inputType="number"
android:maxLength="1"
android:textSize="@dimen/_22sdp" />
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="@dimen/_30sdp"
android:background="@color/colorPrimary"
android:backgroundTint="@color/colorPrimary"
<!-- I want to pass the view object of otp container as a parameter in the method validateOTP()
android:onClick="@{() -> otpViewModel.validateOTP()}"
android:src="@drawable/drawable_fab_proceed"
app:borderWidth="0dp"
app:fabSize="normal"
app:rippleColor="@color/colorAccent" />
</ConstraintLayout>
Please notice the method validateOTP() being invoked in onClick event. I would like to send the view object of linear layout (otp_container) as a parameter. Please help me out for providing me the solution for this.
onClickListenerprogrammatically inside the view.