Pass multi dimension array

Put your problem here if it does not fit any of the other categories.

Pass multi dimension array

Postby pratik goswami » Wed Oct 01, 2008 10:55 am

Hello friends,

I want to pass a two dimension String array from one activity to another activity. How would i set it into Intent.putextra() method and how will i get to another activity by extra.getXXXXX() method???
pratik goswami
Junior Developer
Junior Developer
 
Posts: 19
Joined: Mon Sep 22, 2008 2:54 pm

Top

Re: Pass multi dimension array

Postby MrSnowflake » Thu Oct 02, 2008 2:03 pm

pratik goswami wrote:Hello friends,

I want to pass a two dimension String array from one activity to another activity. How would i set it into Intent.putextra() method and how will i get to another activity by extra.getXXXXX() method???

You should probably use a for-loop:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. for (int x = 0; x < strings.length(); ++x)
  2.  
  3.   for (int y = 0; y < strings[x].length(); ++y)
  4.  
  5.     extra.putString();
  6.  
  7.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

and then do the same for the receiver. Maybe also add 2 ints for the size of the dimensions.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby plusminus » Fri Oct 03, 2008 12:17 am

You could also use :darrow: for looping over the first dimension of your array.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. putStringArray(...)
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Also you might have a look at [font=Courier New]putParcelable()[/font] to ""serialize"" a object, by making it implement the Parcelable Interface.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby MrSnowflake » Fri Oct 03, 2008 10:15 am

Ok, didn't know both. Never worked with parcels before.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 21 guests