How to use data-binding in Dialog?
<p>I am having trouble in implementing databinding in a Dialog. Is it possible?</p>

<p>Below is my xml.</p>

<p>
</p>

<pre><code>&lt;data&gt;

    &lt;variable
        name="olaBooking"
        type="com.example.myapp.viewmodels.ViewModel" /&gt;
&lt;/data&gt;

&lt;LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;

    &lt;android.support.v7.widget.CardView
        android:id="@+id/cv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:elevation="4dp"
        android:padding="15dp"&gt;

        &lt;LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"&gt;

            &lt;TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/colorPrimary"
                android:gravity="center"
                android:padding="15dp"
                android:text="OLA Cab Booked !"
                android:textAppearance="@style/TextAppearance.AppCompat.Body1" /&gt;

            &lt;View
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:background="@color/colorPrimaryDark" /&gt;

            &lt;TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="start|center"
                android:padding="15dp"
                android:text="Car Details" /&gt;

            &lt;View
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:background="@color/colorPrimaryDark" /&gt;

            &lt;TextView
                android:id="@+id/driverName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:text="@{olaBooking.driverName}" /&gt;

            &lt;TextView
                android:id="@+id/carModel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:text="@{olaBooking.getCarName}" /&gt;

            &lt;TextView
                android:id="@+id/carNo"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:text="@{olaBooking.getCabNo}" /&gt;

            &lt;TextView
                android:id="@+id/eta"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:text="@{olaBooking.getEta}" /&gt;
        &lt;/LinearLayout&gt;
    &lt;/android.support.v7.widget.CardView&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p></p>

<p>I want to bind the above layout in a Dialog. How is it possible? Below is my java code i tried but it's not working </p>

<pre><code>        dialog.setContentView(R.layout.dialog_ola_booking_confirmed);
    DialogOlaBookingConfirmedBinding binding = DataBindingUtil.inflate(
            LayoutInflater.from(dialog.getContext()),
            R.layout.dialog_ola_booking_confirmed,
            (ViewGroup) dialog.findViewById(R.id.cv),
            false);
    ViewModel viewModel = new ViewModel(this, event.olaBooking);
</code></pre>