使用Bundle发送2D字符串数组

时间:2014-02-19 08:54:14

标签: android runtime-error bundle multidimensional-array

我想使用我使用的包发送一个2D数组:

//TO SEND
Bundle b = new Bundle();
b.putSerializable("value",string_array);

//TO GET
String[][] array_string = (String[][]) b.getSerializable("value");

但是我收到以下错误:

02-19 08:22:58.582: E/AndroidRuntime(2412): FATAL EXCEPTION: main
02-19 08:22:58.582: E/AndroidRuntime(2412): java.lang.RuntimeException: Unable to start 
activity ComponentInfo{com.example.statlite/com.example.statlite.GraphActivity}: 
java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String[][]

1 个答案:

答案 0 :(得分:0)

In Activity A


String[] arrayName;
Bundle bundle =new Bundle();
bundle.putStringArray("IntentName",arrayName);

In Activity B

String receivingArrayName[]=bundle.getStringArray("IntentName");