tags:

views:

29

answers:

1

Hi, I want to pass a 2-D String Array to another activity. My S2-D String Array (String[][]) is 'selected_list'.

code is : Bundle list_bundle=new Bundle(); list_bundle.putStringArray("lists",selected_list); Intent list_Intent = new Intent(v.getContext(), view_selected_items.class); startActivityForResult(list_Intent, 2); But putStringArray("lists",selected_list) is showing a error like we can pass only 1-Dimensional Array (String[]).

Please give me the solution.. Thanking you..

A: 

You can use putSerializable. Arrays are serializable, provided their elements are.

To store:

list_bundle.putSerializable("lists", selected_list);

To access:

String[][] selected_list = (String[][]) bundle.getSerializable("lists");
Matthew Flaschen
Please tell me if we use putSerializable(), then how to retrieve the String values using getSerializable()?
Miya
Hi Matthew, When I am using that code, my process is suddently stopped. I am new in Android. Please help me. I don't know how to solve this problem.In my second activity, I need to take the String array values and display it to a TextView named 'items'. My code is: Bundle item_bundle=this.getIntent().getExtras(); String [][] selected_list = (String[][]) item_bundle.getSerializable("lists"); TextView items=(TextView) findViewById(R.id.lbl_items); selected_item=selected_list[0][0]+selected_list[0][1]; items.setText(selected_item);
Miya