data binding - Android dataBinding - how to use bool resource to trigger visibility of layout -
i have bool.xml file in android looks this:
<?xml version="1.0" encoding="utf-8"?> <resources> <bool name="showads">true</bool> </resources>
now have layout.xml file uses databinding. want show or hide visilibity of adview based on boolean showads defined above. far have this:
<com.google.android.gms.ads.adview android:id="@+id/adview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="@{@bool/showads ? view.visible:view:gone}" ads:adsize="banner" ads:adunitid="ca-app-pub-1234567/34343">
but not compile. how can boolean decide if ad should show or not ?the syntax wrong.
correct syntax of condition view.visible:view:gone
android:visibility="@{@bool/showads ? view.visible:view.gone}"
and need import view in data section:
<data> <import type="android.view.view"/> </data>
Comments
Post a Comment