Я работаю с привязкой данных Android от активности к макету в виде строки, но она не отображается - PullRequest
2 голосов
/ 04 мая 2019

Я отправляю строку из моей деятельности в макет, который создается как общий макет с привязкой данных, но он не работает.Я проверил много ответов, но у меня ничего не работает.

Я хочу то же, что хочет ОП в следующем вопросе, но принятое им решение не работает для меня.

Передача строки во включенный макет через привязку данных не работает

Ниже приведен мой макет резюме_детали_головок.xml

<?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="sectionTitle"
            type="java.lang.String" />
    </data>

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        app:cardBackgroundColor="@color/app_color_1">

        <TextView
            android:id="@+id/resume_detail_section_heading"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_marginVertical="10dp"
            android:text="@{sectionTitle}"
            android:textAlignment="center"
            android:textColor="@color/color_white"
            android:textSize="20sp" />
    </android.support.v7.widget.CardView>
</layout>

И это моя деятельность, гдеЯ звоню по макету

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@color/color_white"
    >

    <data>

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

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true">

        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.CardView
                android:id="@+id/availablitycardview"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_margin="5dp"
                android:background="@color/color_white">

                <TextView
                    android:id="@+id/availablity"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:text="Available Now"
                    android:gravity="center"
                    android:textColor="@color/color_white"
                    android:textSize="20sp" />
            </android.support.v7.widget.CardView>

            <include
                android:id="@+id/titleRole"
                layout="@layout/resume_detail_heading"
                app:sectionTitle="@{@string/app_name}" />

                <android.support.v7.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="5dp">

                    <ListView
                        android:id="@+id/roles_list"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="5dp"
                        android:scrollbars="none"></ListView>
                </android.support.v7.widget.CardView>
                <!--For Skill-->
                <include
                    android:id="@+id/titleSkill"
                    layout="@layout/resume_detail_heading"
                    app:sectionTitle="@{`Skill`}" />
    ...............
...