相关疑难解决方法(0)

通用图像加载器UIL nostra内存不足错误

我正在使用UIL加载远程图像并填充FragmentStatePagerAdapter中的Fragments.我已阅读自述文件和常见错误,但我无法解决这个错误.

这是配置:

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
    .threadPoolSize(1)
    .build();
    ImageLoader.getInstance().init(config);
Run Code Online (Sandbox Code Playgroud)

这是我显示我的图像的地方:

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {


    ImageLoader imgLoader = ImageLoader.getInstance();

    DisplayImageOptions options = new DisplayImageOptions.Builder()
    .showStubImage(R.drawable.loading)
    .cacheOnDisc()
    .resetViewBeforeLoading()
    .bitmapConfig(Bitmap.Config.RGB_565)
    .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
    .build();

    imgLoader.displayImage(this.contentImage, this.imgView, options);

    return layout;
}
Run Code Online (Sandbox Code Playgroud)

这是我在适配器中销毁我的片段的地方:

public void destroyItem(ViewGroup container, int position, Object object) {
    if (position >= getCount()) {
        container.removeAllViews();
        FragmentManager manager = ((Fragment) object).getFragmentManager();
        FragmentTransaction trans = manager.beginTransaction();
        trans.remove((Fragment) object);
        trans.commit();
    }
}
Run Code Online (Sandbox Code Playgroud)

最后这是我得到的例外:

{
06-20 12:09:24.877: E/dalvikvm-heap(17043): Out of memory on …
Run Code Online (Sandbox Code Playgroud)

android memory-management bitmap universal-image-loader

5
推荐指数
2
解决办法
1万
查看次数