Java代码
1. public class Home extends Activity {
2.
3.
4.
5. public static final String ARRAYS_COUNT = "com.yourname.ARRAYS_COUNT";
6.
7. public static final String ARRAY_INDEX = "com.yourname.ARRAY_INDEX";
8.
9.
10.
11. protected void onCreate(Bundle savedInstanceState) {
12.
13. super.onCreate(savedInstanceState);
14.
15.
16.
17. final String data[][] = new String[][] {{"1","pavan"},{"2","kumar"},{"3","kora"},{"1","pavan"},{"2","kumar"},{"3","kora333"}};
18.
19. Bundle bundle = new Bundle();
20.
21. int count = data.length;
22.
23. bundle.putInt(ARRAYS_COUNT, ARRAY_INDEX );
24.
25. for (int i = 0; i < count; i++)
26.
27. bundle.putStringArray(ARRAY_INDEX + i, data[i]);
28.
29. Intent intent = new Intent(this, Second.class);
30.
31. intent.putExtras(bundle);
32.
33. startActivity(intent);
34.
35.
36.
37. }
38.
39.
40.
41. }
42.
43.
44.
45. public class Second extends Activity {
46.
47.
48.
49. protected void onCreate(Bundle savedInstanceState) {
50.
51. super.onCreate(savedInstanceState);
52.
53.
54.
55. Bundle bundle = getIntent().getExtras();
56.
57.
58.
59. if (bundle != null) {
60.
61. int count = bundle.getInt(Home.ARRAYS_COUNT, 0);
62.
63. ArrayList<String[]> arrays = new ArrayList<String[]>(count);
64.
65. for (int i = 0; i < count; i++)
66.
67. arrays.add(bundle.getStringArray(Home.ARRAY_INDEX + i));
68.
69. String[][] data = arrays.toArray(new String[][]{});
70.
71. }
72.
73. }
74.
75.
76. }
77. Bundle b=new Bundle();
b.putStringArray(key, new String[]{value1, value2});
Intent i=new Intent(context, Class);
i.putExtras(b);
方式有很多,如果你不想new Bundle来传
调用intent的intent.putExtra(name, value)两次就可以了
String[] str1 = {"aa","aa"};
String[] str2 = {"bb","bb"};
Intent intent = new Intent();
intent.putExtra("dev1", str1);
intent.putExtra("dev2", str2);
intent.setClass(this, OtherActivity.class);
startActivity(intent);
在取数据的OtherActivity中
String[] dev = this.getIntent().getStringArrayExtra("dev1");
String[] div = this.getIntent().getStringArrayExtra("dev2");
就拿到了字符串