片段getItem方法仅在下载完成时返回

时间:2013-01-03 08:16:03

标签: android android-asynctask fragment

我的fragments中有View pager,这是getItem方法:

    @Override
public Fragment getItem(int position) {

    fragmentPosition = position;
    Log.e("PageAdapter", "Creating fragment at: " + position);
    DefinedValues.thumbnailInfo.put("activity", DefinedValues.images);
    DefinedValues.thumbnailInfo.put("type", "info");
    DefinedValues.thumbnailInfo.put("page", position+ 1 + "");

    String request = Json.stringToJson(DefinedValues.thumbnailInfo);
    DefinedValues.thumbnailInfo.clear();

    StringAsyncRetriever net = new StringAsyncRetriever();
    net.setListener(MyPagerAdapter.this);
    net.execute(request, DefinedValues.GET_DATA);
    Log.d(TAG, "got item @ " + position);


    myFragment = new fragment1();
    myFragment.position = position;
    return myFragment;
    //return null;      

}

是否可以仅在asyncTask完成而不冻结线程时返回?

0 个答案:

没有答案