在安卓系统中使用SQLite时,我在guide上遇到了问题。我使用的是ListFragment
而不是ListActivity
(如示例所示),因此我让ListFragment
实现LoaderManager.LoaderCallbacks<Cursor>
。然后,在ListFragment
中的fillData()
方法中
private void fillData() {
// Fields from the database (projection)
// Must include the _id column for the adapter to work
String[] from = new String[] { NotesSQLiteHelper.COLUMN_TITLE };
// Fields on the UI to which we map
int[] to = new int[] { R.id.label };
getLoaderManager().initLoader(0, null, this); //error
adapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.notes_row, null, from, to, 0);
setListAdapter(adapter);
}
我得到了错误:
The method initLoader(int, Bundle, LoaderManager.LoaderCallbacks<D>) in the type LoaderManager is not applicable for the arguments (int, null, NotesActivity.ArrayListFragment)
在标记的行上,即使this
实现了LoaderManager.LoaderCallbacks<Cursor>
。
谢谢你的任何想法。
https://stackoverflow.com/questions/11155753
复制相似问题