Maison > Questions et réponses > le corps du texte
写android级联时,报错。
Caused by: java.lang.RuntimeException: setOnItemClickListener cannot be used with a spinner.oid
代码如下:
sp_college.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
arrayAdapter=new ArrayAdapter<CharSequence>(MainActivity.this,android.R.layout.simple_spinner_item,college[i]);
sp_college.setAdapter(arrayAdapter);
}
});
巴扎黑2017-04-17 17:30:46
spinnerView.setOnItemSelectedListener(
new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id) {
showToast("Spinner1: position=" position " id=" id);
}
public void onNothingSelected(AdapterView<?> parent) {
showToast("Spinner1: unselected");
}
});
希望对你有用