views:

237

answers:

2

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

A: 

Either write your own adapter class, extending BaseAdapter, that works with your array, or switch to a different data structure, such as a MatrixCursor.

CommonsWare
A: 

Thank you very much, MatrixCursor worked perfectly!

Yverman
This should be a comment, not an answer.
Techboy