4

I am using concept of Databinding-mvvm to implement such things. I have declared recyclerview into the my mainactivity. like

<layout xmlns:app="http://schemas.android.com/apk/res-auto">
    <data>
        <import type="android.view.View"/>
        <variable
            name="ffvm"
  type="com.example.the_king.apartmentmanagementsystem.ViewModal.
  FragmentViewModal.ViewModal"/>
    </data>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
  tools:context="com.example.the_king.apartmentmanagementsystem.
  Fragment.Fragment_FlatHolder">

 <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
    </FrameLayout>
</layout>

my cardview is look like

<layout>
<data>
    <import type="android.view.View"/>
    <variable
        name="cfhvm"
        type="com.example.the_king.apartmentmanagementsystem.ViewModal.
        CardViewModel.CardViewModal"/>
</data>
  <android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context="com.example.the_king.apartmentmanagementsystem.
    CardView.CardViewFlatHolder"
        layout_width="match_parent"
        android:background="@color/colorPrimaryLight"
        android:elevation="25dp"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp"
        android:innerRadius="15dp"
        android:thicknessRatio="1.9"
        layout_height="match_parent">
<TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@{cfhvm.firstname+` `+cfhvm.lastname}"
                android:layout_marginLeft="5dp"
                android:textSize="@dimen/text_title"
                />
</android.support.v7.widget.CardView>
</layout>

for the cardview i have created viewmodel as cardviewmodal and for Recyclerview i have created viewmodel and i have also created adapter to fill data now i got confuse how do i set value of recyclerview from the viewmodel which contains cardviewmodel.

Dhiral Kaniya
  • 1,941
  • 1
  • 19
  • 32

0 Answers0