我将我的微调器定义如下:
import org.holoeverywhere.widget.Spinner;
private static org.holoeverywhere.widget.Spinner sectionSpinner;
sectionSpinner = (org.holoeverywhere.widget.Spinner)findViewById(R.id.sectionSpinner);
<org.holoeverywhere.widget.Spinner
android:id="@+id/sectionSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/circleSeek"
android:layout_alignParentBottom="true"
android:gravity="center" />
但是,此行会引发错误:
sectionSpinner.setOnItemSelectedListener(new SectionListener());
错误是The method setOnItemSelectedListener(AdapterView.OnItemSelectedListener) in the type AdapterView<SpinnerAdapter> is not applicable for the arguments (MainActivity.SectionListener)
这是 SectionListener 类:
public class SectionListener implements OnItemSelectedListener {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
if (userSelected) {
resetAction();
setTimeText(sectionTimes[pos], sectionTimes[pos]);
currentSection = pos + 1;
setSectionText(currentSection);
currentStartTime = sectionTimes[pos];
currentTime = currentStartTime;
setSeekBarProgress(currentTime, currentStartTime);
}
else {
userSelected = true;
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// Not needed
}
}
当我使用常规的 Android 微调器时,不会发生此错误。有谁知道怎么了?