2
データバインディングを使用して、オブジェクトの文字列フィールド値をXMLファイルの別の文字列値と比較するにはどうすればよいですか?それはxmlファイルでそうすることが可能ですか、私は@BindingAdapter
注釈で私のプロジェクトのどこかにメソッドを作成する必要がありますか? 以下は私がこれまでに試したことであり、うまくいきませんでした。また、ハードコードされた文字列値ではなく、文字列リソース値と比較すると良いでしょう。データバインディングを使用してxmlファイルの文字列を比較する方法
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/male"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="@{user.gender.equalsIgnoreCase("male")}"
android:text="@string/male"/>
<RadioButton
android:id="@+id/female"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="@{user.gender.equalsIgnoreCase("female")}"
android:text="@string/female"/>
</RadioGroup>
ありがとうございました。