- Create/Restart CursorLoader
public void startLoading() {
getLoaderManager().initLoader(0, null, .this);
}
protected void reStartLoading() {
getLoaderManager().restartLoader(0, null, this);
}
- 实现LoaderManager.LoaderCallbacks<Cursor>类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
CursorLoader loader = createCursorLoader(getContext());
mAdapter.configureLoader(loader);
return loader;
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
bindListHeader(data);
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
}
public CursorLoader createCursorLoader(Context context) {
return new DefaultChatbotsLoader(context);
}
- 配置loader
- 绑定Cursor
网友评论