2012-03-15 69 views
0

您好我是新到Android任何一個可以幫助我從這個錯誤...收到一個錯誤,同時通過ArrayList中通過故意

我的代碼看起來像

wheelArrayList = (ArrayList<String>) bundle.get("listData"); 

logcat的:

03-15 18:29:54.967: E/AndroidRuntime(527): FATAL EXCEPTION: main 
03-15 18:29:54.967: E/AndroidRuntime(527): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pack.customadpterforendless/com.pack.customadpterforendless.MainActivity}: java.lang.ClassCastException: java.lang.String 
03-15 18:29:54.967: E/AndroidRuntime(527): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 
03-15 18:29:54.967: E/AndroidRuntime(527): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
03-15 18:29:54.967: E/AndroidRuntime(527): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
03-15 18:29:54.967: E/AndroidRuntime(527): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
03-15 18:29:54.967: E/AndroidRuntime(527): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-15 18:29:54.967: E/AndroidRuntime(527): at android.os.Looper.loop(Looper.java:123) 
03-15 18:29:54.967: E/AndroidRuntime(527): at android.app.ActivityThread.main(ActivityThread.java:4627) 
03-15 18:29:54.967: E/AndroidRuntime(527): at java.lang.reflect.Method.invokeNative(Native Method) 
03-15 18:29:54.967: E/AndroidRuntime(527): at java.lang.reflect.Method.invoke(Method.java:521) 
03-15 18:29:54.967: E/AndroidRuntime(527): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
03-15 18:29:54.967: E/AndroidRuntime(527): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
03-15 18:29:54.967: E/AndroidRuntime(527): at dalvik.system.NativeStart.main(Native Method) 
03-15 18:29:54.967: E/AndroidRuntime(527): Caused by: java.lang.ClassCastException: java.lang.String 
03-15 18:29:54.967: E/AndroidRuntime(527): at com.pack.customadpterforendless.MainActivity.onCreate(MainActivity.java:42) 
03-15 18:29:54.967: E/AndroidRuntime(527): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
03-15 18:29:54.967: E/AndroidRuntime(527): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 
03-15 18:29:54.967: E/AndroidRuntime(527): ... 11 more 

回答

3

您應該使用

getIntent().getXXXArrayListExtra("Name"); 

其中XXX表示對象的什麼ArraList包含,例如,如果你的ArrayList是字符串列表的類型,然後使用

getIntent().getStringArrayListExtra("Name"); 
+0

我如何把它變成意圖像正常或putStringArray(鍵,值) ; – saravana 2012-03-15 13:32:27

+1

使用putStringArrayListExtra(key,value) – 2012-03-15 13:34:49