How can I create a list Array (the list display First Alphabet when scroll) with the cursor data?
+1
A:
Go through every element in the Cursor
, and add them one by one to the ArrayList
.
ArrayList<WhateverTypeYouWant> mArrayList = new ArrayList<WhateverTypeYouWant>();
for(mCursor.moveToFirst(); mCursor.moveToNext(); mCursor.isAfterLast()) {
// The Cursor is now set to the right position
mArrayList.add(mCursor.getWhateverTypeYouWant(WHATEVER_COLUMN_INDEX_YOU_WANT));
}
(replace WhateverTypeYouWant
with whatever type you want to make a ArrayList
of, and WHATEVER_COLUMN_INDEX_YOU_WANT
with the column index of the value you want to get from the cursor.)
Isaac Waller
2009-08-31 16:24:59
Hi, The important thing I want to do is display "Fist character" in my List. After I get all data from cursor, I don't know how to convert it to an String[] Array to get "First character". It look something like this char firstLetter = mString[firstVisibleItem].charAt(0);
Dennie
2009-09-01 03:55:56