Reputation: 39
I am trying the below Usecase :
I am not able to achieve this functionality using Data Binding. Suggestions are welcomed
Upvotes: 0
Views: 274
Reputation: 389
Your question is that much clear for me but in general:
<TextView
android:visibility="@{user.firstName != null ? View.VISIBLE: View.GONE}
...
</TextView>
Supposing that you use User class and depending on a property you can switch visibility of a view:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable name="user" type="com.example.User"/>
</data>
<!-- ... rest of layout here -->
</layout>
If you want to achieve this with a button, you might need to update the property as OnClick action of the button.
Upvotes: 1