答案 0 :(得分:2)
你可以
.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int position, long arg3) {
switch(position) {
//Use cases to set Intents
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// Do Nothing
}
});
答案 1 :(得分:1)
String[] items ={“One”,“Two”,“Three”,“Four”,“Five”};
Spinner sp = (Spinner)findViewById(R.id.Spinner01);
ArrayAdapter<String> adapter =
new ArrayAdapter<String> (this,
android.R.layout.simple_spinner_item,items);
sp.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
switch(position){
case 0:
//call first class
break;
case 1:
//call second class
break;
case 2:
//call third class
break;
case 3:
//call fourth class
break;
default:
break;
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
//nothing selected from spinner
}
});
答案 2 :(得分:0)
只需使用spinner.onItemSelectedListener(new OnItemSelectedListener())
并在onItemSelected(AdapterView adapterview,View视图,int position,long id)方法体中编写逻辑以根据位置开始新活动。