【发布时间】:2012-06-24 17:25:48
【问题描述】:
我在关注guide 在 Android 中使用 SQLite 时遇到问题。我使用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>。
感谢您的任何想法。
【问题讨论】:
-
pastebin.com/284e26tT
filldata()在文件末尾。我更改了包名。我也可能应该提到我正在使用 ActionBarSherlock。
标签: android sqlite android-loadermanager android-listfragment