I have a model class of this JSON
"individualattributepermissionList": [
{
"ATTRIBUTE_NAME": "Age",
"CUSTOM_PERMISSION": true,
"GLOBAL_PERMISSION": false,
},
{
"ATTRIBUTE_NAME": "CHILD_AGES",
"CUSTOM_PERMISSION": false,
"GLOBAL_PERMISSION": false,
},
],
I have the xml Layout for the age attribute
<RelativeLayout
style="@style/mw"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:layout_marginStart="@dimen/dp_22"
android:gravity="center_vertical">
<TextView
style="@style/text_ww_bold"
android:text="@string/age"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:onClick="@{profileVM.selectAge}"/>
<androidx.appcompat.widget.SwitchCompat
style="@style/switch_30"
android:layout_alignParentEnd="true"
android:tag="AGE_G"
android:onCheckedChanged="@{profileVM.checkedChangedListener}"
/>
<androidx.appcompat.widget.SwitchCompat
style="@style/switch_10"
android:tag="AGE_C"
android:layout_alignParentEnd="true"
android:checked="@{profileVM.individualAttributePermission.getCustomPermission}"
android:onCheckedChanged="@{profileVM.checkedChangedListener}"
/>
</RelativeLayout>
I have the attribute name is age and then I have 2 switch buttons for the age like global and custom switch buttons
I need to compare the attribute name as age and then for global switch i need to set Gobalpermission and for custom switch i need to set the custome permission using data binding or in view model class in android java.
How can I compare the attribute age and then set the globalswitch checked or unchecked
question from:
https://stackoverflow.com/questions/65951604/how-to-set-the-switch-button-checked-by-comparing-the-string-using-data-binding 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…