我正在尝试在 Android 上实现加载程序示例,但无法启动加载程序。我正在使用以下代码。它会点击“Create Loader”,但永远不会到达“Loading started”日志消息。我错过了我需要的电话吗?
活动:
public class TestingZoneActivity extends ListActivity implements LoaderCallbacks<ArrayList<Content>>{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getLoaderManager().initLoader(0, null, this);
}
@Override
public Loader<ArrayList<Content>> onCreateLoader(int id, Bundle args) {
Log.e("TEST", "Create Loader");
return new ImageLoader(this);
}
@Override
public void onLoadFinished(Loader<ArrayList<Content>> loader, ArrayList<Content> data) {
setListAdapter(new ImageAdapter(this, data));
}
@Override
public void onLoaderReset(Loader<ArrayList<Content>> loader) {
setListAdapter(null);
}
}
装载机:
public class ImageLoader extends AsyncTaskLoader<ArrayList<Content>> {
public ImageLoader(Context context) {
super(context);
}
@Override
public ArrayList<Content> loadInBackground() {
Log.e("TEST", "Loading started");
}
}