cerealspiller
cerealspiller

Reputation: 1401

Android: An array of arrays and a listview

I've read a java tutorial explaining an "array of arrays" with something similar to coordinates. For instance,

mainArray [0] [0] = "arrayA";
mainArray [0] [1] = 1;
mainArray [0] [2] = 2;
mainArray [1] [0] = "arrayB";
mainArray [1] [1] = 1;

Is it plausable to populate a listview using this type of array in android (using the first set of numbers and not the subset)? I haven't had the chance to try it yet.

Upvotes: 0

Views: 736

Answers (2)

Michele
Michele

Reputation: 6131

Yes, it is possible.

You have to write a custom ListAdapter preferable extending ArrayAdapter.

Look at http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html

Upvotes: 1

Steve Bergamini
Steve Bergamini

Reputation: 14600

A better option would be to define a "coordinates" object and then make an array or list of those objects. Then use that to populate your ListView.

Upvotes: 0

Related Questions