title: Android two-way databinding Float to EditText
body: <p>I am trying to use two-way databinding on a EditText. String values are working fine but I can't get it working for Float values.</p>
  
  <p>I have tried to use a binding adapter that I found in this answer with no luck: <a href="https://stackoverflow.com/questions/41154446/android-databinding-float-to-textview">Android DataBinding float to TextView</a></p>
  
  <p>Then I found this Converter class on the android developers website.
  <a href="https://developer.android.com/topic/libraries/data-binding/two-way#kotlin" rel="noreferrer">https://developer.android.com/topic/libraries/data-binding/two-way#kotlin</a></p>
  
  <pre class="lang-java prettyprint-override"><code>public class Converter {
      @InverseMethod("stringToFloat")
      public static String floatToString(float value) {
          try {
              return String.valueOf(value);
          } catch (Exception e) {
              return "";
          }
      }
  
      public static float stringToFloat(String value) {
          try {
              return Float.parseFloat(value);
          } catch (Exception e) {
              return 0.0f;
          }
      }
  }
  </code></pre>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;com.google.android.material.textfield.TextInputLayout
                              android:layout_width="match_parent"
                              android:layout_height="match_parent"
                              android:layout_marginBottom="16dp"&gt;
  
                              &lt;com.google.android.material.textfield.TextInputEditText
                                  android:id="@+id/width"
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content"
                                  android:hint="Width"
                                  android:inputType="number"
                                  android:text="@={Converter.floatToString(product.width)}"/&gt;
  </code></pre>
  
  <pre><code>data class Product(
          val height: Float?,
          val length: Float?,
          val width: Float?,
          val weight: Float?,       
  ): BaseObservable() {
  </code></pre>
  
  <p>After using the converter class I get the following error when compiling:</p>
  
  <pre><code>error: cannot generate view binders java.lang.NullPointerException at android.databinding.tool.expr.Expr.lambda$join$0(Expr.java:771)
  </code></pre>