Reputation: 461
I have used below code in my layout file to change two different view visibility according to flavor type of the application. I haven't seen any problems with debug build but i believe there is an issue with release build because I have been reported that both views are visible on the test release. Any idea why would this happen?
<Switch
android:id="@+id/configuration_main_network_switch"
style="@style/networkSelector"
android:visibility="@{BuildConfig.FLAVOR.equals(`xxxx`) ? View.GONE : View.VISIBLE}"
android:text="@{configurationMainNetworkSwitch.checked ? @string/network_configuration_main_wifi_enabled_button : @string/network_configuration_main_wifi_disabled_button}" />
<TextView
android:id="@+id/configuration_main_network_switch_gone"
style="@style/networkSelector"
android:visibility="@{BuildConfig.FLAVOR.equals(`xxxx`) ? View.VISIBLE : View.GONE}"
android:text="@string/network_configuration_main_wifi_enabled_button"/>
Upvotes: 1
Views: 1210
Reputation: 76569
Import the required data-types first:
<data>
<import type="com.acme.BuildConfig"/>
<import type="android.view.View"/>
</data>
Then they can be referenced in data-binding statements:
android:visibility="@{ BuildConfig.DEBUG ? View.VISIBLE : View.GONE }"
I can also get the product flavor:
android:text="@{ BuildConfig.FLAVOR }"
Maybe the string being compared to doesn't match?
Upvotes: 0