【发布时间】:2014-06-09 17:20:39
【问题描述】:
我正在尝试在单个页面上创建 2 个微调器。我的代码在 onItemSelected 下方;
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
switch(arg0.getId()) {
case R.id.spinner1:
switch(arg2){
case 0:
Toast.makeText(this, "THIS IS SPINNER 1" , Toast.LENGTH_SHORT).show();
break;
case 1:
Intent intent1 = new Intent(this, Screen2.class);
startActivity(intent1);
break;
case 2:
Intent intent2 = new Intent(this, Screen2.class);
startActivity(intent2);
break;}
case R.id.spinner2:
switch(arg2){
case 0:
Toast.makeText(this, "THIS IS SPINNER 2" , Toast.LENGTH_SHORT).show();
break;
case 1:
Intent intent1 = new Intent(this, Screen3.class);
startActivity(intent1);
break;
case 2:
Intent intent2 = new Intent(this, Screen3.class);
startActivity(intent2);
break;
}
}
}
但是当我运行程序时,这些案例没有像我预期的那样响应,例如微调器 2 在它应该转到 screen2 时将其发送到 screen3
【问题讨论】:
-
"spinner 2 将其发送到 screen3"...听起来正确...检查您的代码,您告诉 spinner2 触发 Screen3.class 的意图...
标签: android spinner onitemselectedlistener