小编vur*_*rp0的帖子

getLoaderManager().initLoader()不接受'this'作为参数,尽管类(ListFragment)实现了LoaderManager.LoaderCallbacks <Cursor>

我在遵循Android中使用SQLite 的指南时遇到了麻烦.我正在使用a ListFragment而不是ListActivity(如示例中所示),所以我使用了ListFragment工具LoaderManager.LoaderCallbacks<Cursor>.然后,在以下fillData()方法中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);
}
Run Code Online (Sandbox Code Playgroud)

我收到错误:

The method …
Run Code Online (Sandbox Code Playgroud)

sqlite android android-listfragment android-loadermanager

64
推荐指数
3
解决办法
5万
查看次数

ActionBarSherlock给出了大量的"Call requires API level 11(current min is 7)"错误

我下载了ActionBarSherlock 4.0.3,解压缩并从该library文件夹中创建了一个新项目.src根据Eclipse,该文件夹充满了错误,因此我在线遵循各种指令,例如添加android-support-v4.jar,将目标API设置为15,将编译器合规性级别设置为1.6.尽管如此,该项目还有194个错误,所有错误都是"呼叫要求API级别11(当前最小值为7)".所以当我看到其中一个错误时,我看到了这个:

@Override
public void invalidateOptionsMenu() {
    getSherlock().dispatchInvalidateOptionsMenu();
}

public void supportInvalidateOptionsMenu() {
    invalidateOptionsMenu();
    //the previous line has this error in Eclipse:
    //Call requires API level 11 (current min is 7): android.app.Activity#invalidateOptionsMenu
}
Run Code Online (Sandbox Code Playgroud)

这看起来很奇怪,因为invalidateOptionsMenu()被前一个函数覆盖了,但是Eclipse仍然抱怨需要更新的API级别的函数.当我查看其他错误时,我发现这也是许多其他错误的情况.

我对Python的经验比Java要多,所以我不明白导致这种情况发生的原因.帮助将不胜感激,如果您提供帮助,您是否还可以解释导致此问题的原因以及您采取了哪些措施来解决问题?每次遇到问题我都不想问别人,我也想学习.

android actionbarsherlock

18
推荐指数
3
解决办法
3万
查看次数