title: Android - Data Binding - String Attribute with Expression
body: <p>I have been struggling with an almost unsolvable issue with Android lately.
  I'm trying to build a custom control that would take one of its value dynamically from a function.
  But with no avail.
  Here is the attrs.xml entry:</p>
  
  <pre><code>&lt;declare-styleable name="BinaryOptionButtonAttrs"&gt;
  &lt;attr name="binaryText" format="string"/&gt;
  &lt;attr name="binaryValue" format="string"/&gt;
  &lt;attr name="binaryDirection" format="enum"&gt;
      &lt;enum name="up" value="0x00"/&gt;
      &lt;enum name="down" value="0x01"/&gt;
  &lt;/attr&gt;&lt;/declare-styleable&gt;
  </code></pre>
  
  <p>Here is the custom control view code:</p>
  
  <pre><code>public class BinaryOptionButton extends LinearLayout {
  private Context mContext;
  private String mText;
  private String mValue;
  private BINARY_OPTION mDirection;
  
  public BinaryOptionButton(Context context) {
      super(context);
  }
  
  public BinaryOptionButton(Context context, AttributeSet attrs) {
      super(context, attrs);
      mContext = context;
      initAttrArray(attrs);
      initBinaryOptionButton();
  }
  
  public String getBinaryText() {
      return mText;
  }
  
  public void setBinaryText(String mText) {
      this.mText = mText;    }
  
  public String getBinaryValue() {
      return mValue;
  }
  
  public void setBinaryValue(String mValue) {
      this.mValue = mValue;        Log.d(this.getClass().getPackage().getName(),
              "BinaryOptionButton.mValue=" + mValue);
  }
  
  public BINARY_OPTION getBinaryDirection() {
      return mDirection;
  }
  
  public void setBinaryDirection(BINARY_OPTION mDirection) {
      this.mDirection = mDirection;
  }
  
  private void initBinaryOptionButton() {
  
  }
  
  private void initAttrArray(AttributeSet attrs) {
      TypedArray attrsArray   = mContext.obtainStyledAttributes(attrs,
              R.styleable.BinaryOptionButtonAttrs, 0, 0);
  
      mText = attrsArray.getString(
              R.styleable.BinaryOptionButtonAttrs_binaryText
      );
  
      mValue = attrsArray.getString(
              R.styleable.BinaryOptionButtonAttrs_binaryValue
      );
  
      mDirection = BINARY_OPTION.parseInt(attrsArray.getInt(
              R.styleable.BinaryOptionButtonAttrs_binaryDirection,
              BINARY_OPTION.UP.value()
      ));
      Log.d(this.getClass().getPackage().getName(),
              "mText=" + mText);
  
      Log.d(this.getClass().getPackage().getName(),
              "mValue=" + mValue);
  
      Log.d(this.getClass().getPackage().getName(),
              "mDirection=" + mDirection);
  
      attrsArray.recycle();
  } }
  </code></pre>
  
  <p>Here is a sample usage of the Custom View:</p>
  
  <pre><code>&lt;layout  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:bind="http://schemas.android.com/apk/res-auto"&gt;
  &lt;data&gt;
      &lt;import type="Utils"/&gt;
      &lt;variable
          name="HANDLER"
          type="ViewListener"/&gt;
      &lt;variable name="dataCount" type="int"/&gt;
      &lt;variable name="dataVector" type="java.util.List"/&gt;
  &lt;/data&gt;&lt;RelativeLayout
  android:layout_width="match_parent" android:layout_height="match_parent"&gt;
  &lt;com.package.BinaryOptionButton
  android:id="@+id/btn"
  android:layout_width="150dp"
  android:layout_height="100dp"
  bind:binaryText='@{"BUY"}'
  bind:binaryValue="@{Integer.toString(dataCount)}"
  bind:binaryDirection="@{Utils.binary(dataVector)}"    
  android:onClick='@{() -&gt; HANDLER.onAction("data")}'/&gt;&lt;/RelativeLayout&lt;/layout&gt;
  </code></pre>
  
  <p>The Attribute binaryText shows "BUY". However, the Attributes binaryValue and binaryDirection are NEVER even called!</p>
  
  <p>What I'm doing wrong here?</p>
  
  <p>Thanks</p>