DataBinding: Choose one of string resources depends on condition

android, android-databinding

Solution

The `Databinding` library is lost when you use the . (dot) as a name, change your `strings.xml` file to this:

  <string name="sharebox_bcc_mode_on">BCC mode on</string>
  <string name="sharebox_bcc_mode_off">BCC mode off</string>

Problem

I have a boolean variable in my data-object, and want to show 1 string from resources when it is true, and another when it is false. I am trying to do it this way: ``` android:text="@{sendit.bccMode ? @string/sharebox.bcc_mode_on : @string/sharebox.bcc_mode_off}" ``` But getting an compilation error: ****/ data binding error ****msg:Could not find accessor java.lang.String.bcc_mode_on What do I am doing wrong?

Original source