I want to import some string from interface constant in android layout data binding.
Gradle build fails if i use this line
android:drawableRight="@{item.icon.equalsIgnoreCase(Constants.FOOD_TYPE_NON_VEG)? @drawable/ic_nonveg : @drawable/ic_veg}"
But below line works
android:drawableRight="@{item.icon.equalsIgnoreCase(`nonveg`)? @drawable/ic_nonveg : @drawable/ic_veg}"
Sample xml is
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="Constants"
type="com.amelio.utils.Constants"/>
</data>
<TextView
style="@style/tvVerySmall"
android:layout_width="match_parent"
android:drawableRight="@{item.icon.equalsIgnoreCase(`nonveg`)? @drawable/ic_nonveg : @drawable/ic_veg}"
/>
</layout>
and Constants interface is
public interface Constants {
String FOOD_TYPE_NON_VEG = "nonveg";
}
How to import string from interface in xml layout in databinding?