title: Auto generate age when date is set using datepicker - Android Xamarin
body: <p>how to auto generate the and edittext when the datepicker is set?</p>
  
  <p>my xml file look like this:</p>
  
  <pre><code>        &lt;TextView
              android:text="Birthdate:"
              android:textAppearance="?android:attr/textAppearanceMedium"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
          &lt;DatePicker
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/in_bDate"
              android:calendarViewShown="false"
              android:datePickerMode="spinner"
              android:spinnersShown="true" /&gt;
          &lt;TextView
              android:text="Age:"
              android:textAppearance="?android:attr/textAppearanceMedium"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
          &lt;EditText
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/in_age"
              android:layout_marginBottom="10dp" /&gt;
  </code></pre>
  
  <p>and my cs file looks like this:</p>
  
  <pre><code>        DatePicker bDate = FindViewById&lt;DatePicker&gt;(Resource.Id.in_bDate);
          EditText age = FindViewById&lt;EditText&gt;(Resource.Id.in_age);
  
          bDate.Click += delegate {
              var year = DateTime.Now.Year;
              int auto_age = year - bDate.Year;
              age.SetText(auto_age.ToString(), TextView.BufferType.Editable);
          };
  </code></pre>
  
  <p>edit: changed the methods in setting the content of age</p>