1
私はSpinnerを含む2ウェイデータバインディングを実装しています。次のエラーが表示されます。どんな助けもありがたい。@BindingAdapter getSelectedItemPosition(android.widget.Spinner)には1つの属性と0の値パラメータがあります。 1つまたは2つの値パラメータがあるはずです
エラー:(105,16)エラー:@BindingAdapter getSelectedItemPosition(android.widget.Spinner)には1つの属性と0の値パラメータがあります。 1つまたは2つの値パラメータが必要です。ここで
は私のコードは
モデルコード
@BindingAdapter({"bind:selection"})
public int getSelection(Spinner view) {
return view.getSelectedItemPosition();
}
@BindingAdapter({"bind:selection"})
public void setSelection(Spinner view, int position) {
view.setSelection(position);
notifyPropertyChanged(BR.position);
}
XMLコード
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<variable
name="payment"
type="com.ananth.finance.model.MakePayment" />
</data>
<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Spinner
android:id="@+id/paymentName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:entries="@{payment.allPayments}"
android:selection="@={payment.selectedItemPosition}"
android:padding="7dp" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
</layout>