Bind variable not set in XML layout

Viewed 51

I've got a simple layout:

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

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:focusableInTouchMode="true"
        >

        <include  layout="@layout/toolbar_returnicon_text"
            android:id="@+id/abLayoutAddVehicle"
            bind:tvText="@{@string/_1_tank}"
            />

    </RelativeLayout>
</ScrollView>

Which imports the following layout:

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

        <data>
            <variable name="tvText" type="java.lang.String"/>
        </data>

        <com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/BrightYellowCrayola"
            >

                <androidx.appcompat.widget.Toolbar
                    android:id="@+id/tbReturn"
                    app:navigationIcon="@drawable/outline_arrow_back_24"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:popupTheme="@style/AppTheme.PopupOverlay"
                    >

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{tvText}"
                            android:layout_gravity="center"
                            android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
                            android:id="@+id/toolbar_title" />
                </androidx.appcompat.widget.Toolbar>

        </com.google.android.material.appbar.AppBarLayout>
</layout>

The issue is that the bind variable tvText won't appear in the layout when I start my application. Few things I've tried:

  • using app instead of bind
  • using hardcoded string value rather than string.xml string value
  • putting brackets before and after string value

What am I doing wrong/missing?

0 Answers
Related