Search code examples
androidandroid-databinding

Android + Data Binding @style


While using the new data binding api, I found that you can't bind to the "style" attribute. Compiler complains that it can't find the style. However, if I simply set the style as is, it'll find it just fine. For example:

doesn't work:

style="@{TextUtils.isEmpty(row.getSubtitle()) ? @style/SubTitle : @style/Title}"

works:

style="@style/SubTitle"

Error:

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.

java.lang.RuntimeException: Found data binding errors. ****/ data binding error ****msg:Identifiers must have user defined types from the XML file. SubTitle is missing it file:/~/test/app/src/main/res/layout/row.xml loc:48:71 - 48:78 ****\ data binding error ****


Solution

  • The data binding unfortunately is not supported for styles: https://code.google.com/p/android-developer-preview/issues/detail?id=2613