Android 台灣中文網

標題: spinner 連到下一個 activity [已解決] [打印本頁]

作者: f9999200    時間: 2012-7-30 16:06
標題: spinner 連到下一個 activity [已解決]
本帖最後由 f9999200 於 2012-8-3 12:59 編輯

下面是我寫的OnItemSelectedListener  不知道哪裡有錯
因為當我選擇spinner 的選項的時候,他卻會把所有的activity都打開,而且還會發生當我選第一個選項時,卻跳到第二個選項的activity

請各位大大教我怎麼改才好
  1. class SpinnerSelectedListener implements OnItemSelectedListener{  
  2.    
  3.         public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,  
  4.                 long arg3) {
  5.                
  6.                 int index = arg0.getSelectedItemPosition();
  7.                 switch(index){
  8.                 case 1:   
  9.                         Intent intent=new Intent();
  10.                         intent.setClassName("com.yesgogo","com.saxfortcmk.SaxTaipeiCityMK");
  11.                         startActivity(intent);       
  12.                 case 2:  
  13.                         Intent intent2 = new Intent();
  14.                         intent2.setClassName("com.yesgogo","com.saxforkcmk.SaxKeelongCityMK");
  15.                         startActivity(intent2);  
  16.                 case 3:
  17.                         Intent intent3 = new Intent();
  18.                         intent3.setClassName("com.yesgogo","com.saxfornewtcmk.SaxNewTaipeiCityMK");
  19.                         startActivity(intent3);  
  20.                 }
  21.         }  
  22.         public void onNothingSelected(AdapterView<?> arg0) {  
  23.         }  
  24.     }
複製代碼
===========================================================

感謝       "iceblue7x"            指點



作者: iceblue7x    時間: 2012-7-31 08:21
每個 case 結尾要加 break;




歡迎光臨 Android 台灣中文網 (https://apk.tw/) Powered by Discuz! X3.1