Android 台灣中文網
標題:
spinner 連到下一個 activity [已解決]
[打印本頁]
作者:
f9999200
時間:
2012-7-30 16:06
標題:
spinner 連到下一個 activity [已解決]
本帖最後由 f9999200 於 2012-8-3 12:59 編輯
下面是我寫的OnItemSelectedListener 不知道哪裡有錯
因為當我選擇spinner 的選項的時候,他卻會把所有的activity都打開,而且還會發生當我選第一個選項時,卻跳到第二個選項的activity
請各位大大教我怎麼改才好
class SpinnerSelectedListener implements OnItemSelectedListener{
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
int index = arg0.getSelectedItemPosition();
switch(index){
case 1:
Intent intent=new Intent();
intent.setClassName("com.yesgogo","com.saxfortcmk.SaxTaipeiCityMK");
startActivity(intent);
case 2:
Intent intent2 = new Intent();
intent2.setClassName("com.yesgogo","com.saxforkcmk.SaxKeelongCityMK");
startActivity(intent2);
case 3:
Intent intent3 = new Intent();
intent3.setClassName("com.yesgogo","com.saxfornewtcmk.SaxNewTaipeiCityMK");
startActivity(intent3);
}
}
public void onNothingSelected(AdapterView<?> arg0) {
}
}
複製代碼
===========================================================
感謝 "iceblue7x" 指點
作者:
iceblue7x
時間:
2012-7-31 08:21
每個 case 結尾要加 break;
歡迎光臨 Android 台灣中文網 (https://apk.tw/)
Powered by Discuz! X3.1