views:

15

answers:

1

Hi I want to pass an Arraylist from one activity to another. I use putStringArrayListExtra(), but there shows an error : "The method putStringArrayListExtra(String,ArrayList is undefined for the type bundle." Is there any other method available for passing ArrayList?

  String test[]=new String[3];
  ArrayList<String[]> al=new ArrayList<String[]>(); 
  int x,y; 

               test[0]="1"; 
               test[1]="2"; 
               test[2]="3"; 
               al.add(test); 

               test = new String[3];
               test[0]="4"; 
               test[1]="5"; 
               test[2]="6"; 
               al.add(test); 

              Bundle list_bundle=new Bundle();
              list_bundle.putStringArrayListExtra("lists",al);
              Intent list_intent= new Intent(v.getContext(), view_all_selected.class);
              list_intent.putExtras(list_bundle);
              startActivityForResult(list_intent, 2);

Please help me..

A: 

Hello,

putStringArrayListExtra is a method of Intent class. In the code above try to call:

list_intent.putStringArrayListExtra("lists",al);

and remove these lines:

Bundle list_bundle=new Bundle(); list_bundle.putStringArrayListExtra("lists",al); list_intent.putExtras(list_bundle);

Alexey