Newbee question:
Both snippets below work, either from string array or cursor from SQLite table.
Now, how do I get these values from the table into a string array so I can manipulate them, then display them as a lstAdapter?
(I can provide the complete source but 14 pages 10 pt. minimal heading footer before lots of comments added).
I have tried lots of samples from here and other places. Most generate errors I haven't figured out, rest don't work, so I am missing something.
This structure will eventually be part of an app for my WIMM One, so it needs to be Android version 7.
//From my ...ListFragment:
//This works; I get "First", "Second", etc. listed on my screen:
//-----------------------
private SimpleCursorAdapter mAdapter;
private ListAdapter lstAdapter;
. . .
Log.d("RemindLF","S onCrt: NEW");
// an array of string items to be displayed
String[] strLstitems = new String[]
{"first", "Second", "Third", "Fourth"};
//
lstAdapter = new ArrayAdapter<String>(getActivity(),
R.layout.reminder_row, R.id.text1, strLstitems);
//
// Call to SetListAdapter()informs ListFragment how to fill ListView
setListAdapter(lstAdapter);
getLoaderManager().initLoader(0, null, this);
Log.d("RemindLF","X onCrt:" + strLstitems[0]);
//This also works; I get the values of one column from each record listed on my screen
//--------------------------
private ArrayAdapter aryAdapter;
. . .
Log.d("RemindLF","X onCrt: BASE" );
String[] strItems = new String[]
{
ReminderProvider.COLUMN_BODY
};
Log.d("RemindLF","X onCrt:strI:" + strItems[0]);
int[] iCnt = new int[]
{
R.id.text1
};
mAdapter = new SimpleCursorAdapter(getActivity(),R.layout.reminder_row,
null, strItems, iCnt, 0);
setListAdapter(mAdapter);
getLoaderManager().initLoader(0, null, this);
//Other pieces
//------------
//Loader set-up:
@Override
public Loader<Cursor> onCreateLoader(int ignored, final Bundle args)
{
Log.d("RemindLF","S LoadCSR");
return new CursorLoader(getActivity(), ReminderProvider.CONTENT_URI, null, null, null, null);
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor)
{
Log.d("RemindLF","S LoadFin");
mAdapter.swapCursor(cursor);
}
REMINDER_LIST.XM:L
<?xml version="1.0" encoding="utf-8"?>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.dummies.android.taskreminder.ReminderListFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
REMINDER_ROW.XML:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip" />