Trying to set visibility of View
using custom variable, but error occurs: Identifiers must have user defined types from the XML file. visible is missing it
. Is it possible to set view visibility using data binding? Thanks.
<data>
<variable
name="sale"
type="java.lang.Boolean"/>
</data>
<FrameLayout android:visibility="@{sale ? visible : gone}"/>
As stated in the Android Developer Guide, you need to do it like this:
<data>
<import type="android.view.View"/>
<variable
name="sale"
type="java.lang.Boolean"/>
</data>
<FrameLayout android:visibility="@{sale ? View.GONE : View.VISIBLE}"/>