In order to make my app code cleaner, I try to create common xml but I am getting an error like below:
error: activity_login.xml:230: AAPT: error: attribute buttonTitle
In my Login.xml file:
<include
android:id="@+id/login_button"
layout="@layout/widget_large_button"
app:buttonTitle="@string/login"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"/>
and I have defined the layout as below:
<data>
<variable
name="buttonTitle"
type="String"/>
</data>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="16dp"
android:background="@drawable/stripe_backgound_05"
android:clickable="false"
android:focusable="false"
android:letterSpacing="0.5"
android:paddingTop="25dp"
android:paddingBottom="25dp"
android:text="@{buttonTitle}"
android:textAllCaps="true"
android:textColor="@color/gainsboro_05"
android:textSize="16sp"/>
It seems that I can't pass the buttonTitle from the login.xml to the button widget.
Any idea?
Thanks
Try to add
bind:buttonTitle="@{'variable name of login.xml'}"
in the include tag