title: How to use Two way data binding with radio button in android
body: <p>I am trying to use two way data binding with the radio button. It is working fine with one way like below,</p>
  
  <p><code>android:checked="@{registration.gender.equals(Gender.FEMALE.getValue())}"</code>. </p>
  
  <p>But My problem is that, I need to set the value of selected radio button in my model.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
     &lt;data&gt;
        &lt;import type="com.callhealth.customer.comman.enums.Gender" /&gt;
        &lt;import type="android.text.TextUtils" /&gt;
        &lt;import type="java.lang.Integer" /&gt;
        &lt;variable name="callback" type="com.callhealth.customer.usermanagement.callback.RegistrationCallback" /&gt;
        &lt;variable name="registration" type="com.callhealth.customer.usermanagement.model.request.LoginAndRegistrationRequestModel" /&gt;
     &lt;/data&gt;
     &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:orientation="vertical"&gt;
        &lt;android.support.v7.widget.AppCompatTextView android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/label_gender" android:textSize="15sp" /&gt;
        &lt;RadioGroup android:id="@+id/gender_group" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:orientation="horizontal"&gt;
           &lt;android.support.v7.widget.AppCompatRadioButton android:layout_width="wrap_content" android:checked="@={registration.gender.equals(Gender.MALE.getValue())}" android:layout_height="wrap_content" android:text="@string/label_male" /&gt;
           &lt;android.support.v7.widget.AppCompatRadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginStart="20dp" android:checked="@={registration.gender.equals(Gender.FEMALE.getValue())}" android:text="@string/label_female" /&gt;
        &lt;/RadioGroup&gt;
     &lt;/LinearLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p>My Model Class</p>
  
  <pre><code>public class LoginAndRegistrationRequestModel extends BaseObservable {
  
      private Integer gender;
  
      @Bindable
      public Integer getGender() {
          return gender;
      }
  
      public void setGender(Integer gender) {
          this.gender = gender;
          notifyPropertyChanged(BR.gender);
      }   
  }
  </code></pre>
  
  <p>When i am trying to use </p>
  
  <pre><code>android:checked="@={registration.gender.equals(Gender.FEMALE.getValue())}" 
  </code></pre>
  
  <p>Gradel is throwing an error </p>
  
  <pre><code>Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
  &gt; android.databinding.tool.util.LoggedErrorException: Found data binding errors.
    ****/ data binding error ****msg:The expression registrationGender.equals(com.callhealth.customer.comman.enums.Gender.MALE.getValue()) cannot be inverted: There is no inverse for method equals, you must add an @InverseMethod annotation to the method to indicate which method should be used when using it in two-way binding expressions
    file:S:\Umesh\android\android_studio_workspace\CallHealth\app\src\main\res\layout\content_user_registration.xml
    loc:148:48 - 148:97
    ****\ data binding error ****
  </code></pre>