6

我正在尝试将参数传递给 AsyncTaskLoader。我怎么做?

目前,我将需要传递的内容放入单独的静态类中。无论如何围绕这个?

public class NewsAsyncTaskLoader extends AsyncTaskLoader<List<Content>> {

    private static final DbHelper dbHelper = DbHelperFactory.getDbHelper();

    public FeedAsyncTaskLoader(Context context) {
        super(context);
    }

    @Override
    public List<Content> loadInBackground() {
        List<Content> contents = DbHelper.getStream(FeedSections.getInstance().getCurrentSection());

        feed.setContents(contents);

        return feed;
    }
}
4

1 回答 1

18

将其他参数传递给您的构造函数:

public FeedAsyncTaskLoader(Context context, String moreInfo) {
    super(context);
    // Do something with moreInfo
}
于 2013-09-12T23:11:17.480 回答