我正在使用fragmnet中的加载器。我已经实施了LoaderManager.LoaderCallbacks<Cursor>
但我仍然收到错误“类型initLoader(int,Bundle,LoaderManager.LoaderCallbacks<D>)
中的方法LoaderManager
不适用
参数(int, null, Details)
“
package com.example.ms;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.app.LoaderManager;
import android.content.Loader;
import android.database.Cursor;
import android.support.v4.content.CursorLoader;
import android.support.v4.widget.CursorAdapter;
public class Details extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {
private static final int LIST_ID =0;
String University_name;
Long id;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v= inflater.inflate(R.layout.details, container, false);
TextView Name=(TextView)v.findViewById(R.id.university_name);
Name.setText(University_name);
}
public void onCreate(Bundle savedInstanceState)
{ TaskList tl=(TaskList)getActivity();
Bundle bundle=tl.sendData();
University_name=bundle.getString("UniName");
id=bundle.getLong("id");
getLoaderManager().initLoader(LIST_ID, null,this);
}
@Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor arg1) {
// TODO Auto-generated method stub
}
@Override
public void onLoaderReset(Loader<Cursor> arg0) {
// TODO Auto-generated method stub
}
我的代码不完整,我还没有实现加载器方法
答案 0 :(得分:3)
您必须使用getSupportLoaderManager()
方法而不是getLoaderManager
答案 1 :(得分:0)
我使用了getSupportLoadermanager(),但仍显示错误。所以我在FragmentActivity类中实现了LoaderManager,并通过包将我从数据库检索到的数据传递给了Fragment