Ich implementiere 2-Wege-Datenbindung mit einem Spinner. Ich erhalte den folgenden Fehler. Jede Hilfe wird geschätzt.@BindingAdapter getSelectedItemPosition (android.widget.Spinner) hat 1 Attribute und 0 Wertparameter. Es sollte 1 oder 2 Wertparameter geben
Fehler: (105, 16) Fehler: @BindingAdapter getSelectedItemPosition (android.widget.Spinner) hat 1 Attribute und 0 Wertparameter. Es sollte 1 oder 2 Wertparameter geben.
Hier ist mein Code
Modell Code
@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-Code
<?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>