[Java/Android] Multidimensional array to ListView.. how?
- by Yverman
I have a query result set which I like to edit first and then put it to my ListView. Without editing my data first, I could use SimpleCursorAdapter like that:
ListAdapter adapter = new SimpleCursorAdapter(
this,
R.layout.list_item,
mCursor,
new String[] { "address", "city" },
new int[] { R.id.address, R.id.zip_city });
this.setListAdapter(adapter);
But now, I put everything in a multidimensional array like that:
if(mCursor.isFirst()) {
//create a new array
String[][] listData = new String[mCursor.getCount()][3];
int i = 0;
do {
listData[i] = new String[] {
mCursor.getString(mCursor.getColumnIndex("address")),
mCursor.getString(mCursor.getColumnIndex("zip")) + " " + mCursor.getString(mCursor.getColumnIndex("city")),
calculateDistance(Double.parseDouble(mCursor.getString(mCursor.getColumnIndex("diff"))))
};
i++;
} while(mCursor.moveToNext());
}
So my problem is now, I have no idea how to put this to my ListView. Could someone help me here? Sorry for my bad english and Java knowledge. :)