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 开发者_如何学Goand not the subset)? I haven't had the chance to try it yet.
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
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.
精彩评论