开发者

problems with putStringArrayListExtra() in Android

开发者 https://www.devze.com 2023-01-21 08:33 出处:网络
Hi I want to pass an Arraylist from one activity to another. I use putStringArrayListExtra(), but there shows an error :

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..


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消