getLoaderManager().initLoader() n'accepte pas le " il " comme argument de la classe (ListFragment) met en œuvre LoaderManager.LoaderCallbacks<Curseur>

J'ai de la difficulté à la suite d'une guide sur l'utilisation de SQLite sous Android. Je suis à l'aide d'un ListFragment au lieu d'un ListActivity(comme dans l'exemple), j'ai donc le ListFragment mettre en œuvre LoaderManager.LoaderCallbacks<Cursor> à la place. Puis, dans la fillData() méthode dans le ListFragment:

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);
}

J'obtiens l'erreur:

The method initLoader(int, Bundle, LoaderManager.LoaderCallbacks<D>) in the type LoaderManager is not applicable for the arguments (int, null, NotesActivity.ArrayListFragment)

sur la ligne marquée, même si this implémente LoaderManager.LoaderCallbacks<Cursor>.

Merci pour toutes les idées.

  • collez votre code.
  • pastebin.com/284e26tT filldata() est à la fin du fichier. J'ai changé le nom du package. J'ai aussi devrait probablement avoir mentionné que je suis en utilisant ActionBarSherlock.
InformationsquelleAutor vurp0 | 2012-06-22