android this参数,initLoader调用不会将“this”作为第三个参数。下面“在 'android.support.v4.app.LoaderManager...

initLoader(INT,android.os.Bundle,android.support.v4.app.LoaderManager.LoaderCallbacks)全部错误' 不能是应用于'(int,null,group15.cop4331project.MyReportsFragment)

我已阅读关于支持库的所有答案,但事实并非如此。我试图用SQLite数据库中的列表来填充这个片段。我真的很想弄清楚为什么这不起作用。此外,我认为我正确使用OnCreateView和OnActivityCreated,但我不确定。

我进口

import android.content.ContentUris;

import android.content.Intent;

import android.net.Uri;

import android.os.Bundle;

import android.support.v4.app.Fragment;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.widget.AdapterView;

import android.widget.ListView;

我的代码

public class MyFragment extends Fragment implements LoaderManager.LoaderCallbacks {

//adapter for the ListView

MyCursorAdapter mCursorAdapter;

View rootView;

public MyReportsFragment() {

// Required empty public constructor

}

@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

rootView = inflater.inflate(R.layout.report_list, container, false);

return rootView;

}

@Override

public void onActivityCreated(Bundle savedInstanceState) {

super.onActivityCreated(savedInstanceState);

// Find the listview which will be populated with the data

ListView listView = (ListView) rootView.findViewById(R.id.list);

// Setup an Adapter to create a list item for each row of data in the Cursor.

mCursorAdapter = new ReportCursorAdapter(getActivity(), null);

listView.setAdapter(mCursorAdapter);

// Setup the item click listener

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {@Override

public void onItemClick(AdapterView < ?>adapterView, View view, int position, long id) {

Intent intent = new Intent(getActivity(), EditReportActivity.class);

Uri currentUri = ContentUris.withAppendedId(ReportEntry.CONTENT_URI, id);

// Set the URI on the data field of the intent

intent.setData(currentUri);

startActivity(intent);

}

});

// Kick off the loader

getLoaderManager().initLoader(REPORT_LOADER, null, this);

//getActivity().getSupportLoaderManager().initLoader(REPORT_LOADER, null, this);

}

}

2017-03-04

bous006

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值