为了账号安全,请及时绑定邮箱和手机立即绑定

为什么 getLoaderManager.initLoader() 第三个参数 = 这个无效?

为什么 getLoaderManager.initLoader() 第三个参数 = 这个无效?

largeQ 2023-01-05 16:57:46

在 Udacity ND..Pet 应用程序中,在扩展 AppCompaActivity 和实现 LoaderManager.LoaderCallbacks 的活动中调用 getLoaderManager.initLoader(0,null,this); 显示第三个参数无效的错误。


//THESE ARE SOME OF THE IMPORT STATEMENTS;


import android.support.v4.app.LoaderManager;    

import android.support.v4.content.CursorLoader; 

import android.support.v4.content.Loader;       

import android.support.v7.app.AppCompatActivity;

public class CatalogActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor> {


/** Database helper that will provide us access to the database */

private PetDbHelper mDbHelper;

PetCursorAdapter mCursorAdapter;

@Override

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_catalog);


    // Setup FAB to open EditorActivity

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

    fab.setOnClickListener(new View.OnClickListener() {

            @Override

        public void onClick(View view) {

            Intent intent = new Intent(CatalogActivity.this, EditorActivity.class);

            startActivity(intent);

        }

    });

    ListView listView = (ListView) findViewById(R.id.listview);

    View emptyListView = (View) findViewById(R.id.empty_view);

    listView.setEmptyView(emptyListView);

    //mDbHelper = new PetDbHelper(this);

    mCursorAdapter = new PetCursorAdapter(this,null);

    listView.setAdapter(mCursorAdapter);

    getLoaderManager().initLoader(0,null,this);<-----HERE

    // To access our database, we instantiate our subclass of SQLiteOpenHelper

    // and pass the context, which is the current activity.

}


查看完整描述

1 回答

?
炎炎设计

TA贡献1559条经验 获得超3个赞

只需将您的导入替换 import android.support.v4.app.LoaderManager; 为 import android.app.LoaderManager;



查看完整回答
反对 回复 2023-01-05

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信