本文介绍了毕加索仅在BaseAdapter中加载一张图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在BaseAdapter的getView()中,我使用URL和Picasso将图像加载到ImageView中.不幸的是,只加载了一张图像.这是getView()代码:

In the getView() of a BaseAdapter I load an image into a ImageView using a URL and Picasso. Unfortunately only one image is being loaded. Here is the getView() code :

 @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            LayoutInflater inflater = (LayoutInflater) mFragment.getActivity().getSystemService(Context
                    .LAYOUT_INFLATER_SERVICE);
            view = inflater.inflate(R.layout.layout_card, viewGroup, false);

        }


        Log.d("ParseUrl", mCardList.get(i).getProfilePictureFiles().get(0).getUrl());
        ImageView image = (ImageView) view.findViewById(R.id.image);

        Picasso.with(mFragment.getActivity()).load(mCardList.get(i).getProfilePictureFiles().get(0)
                .getUrl()).into(image);
        TextView name = (TextView) view.findViewById(R.id.name);
        name.setText(mCardList.get(i).getUser().getString(Keys.NAME_STR));

        return view;
    }

一些更奇怪的行为:如果我尝试将URL更改为静态imgur图像,则只会加载2/3,并且当我刷新片段时,会加载所有图像,因为它们已被缓存.

Some more strange behavior: If I try changing the URL to a static imgur image, only 2/3 are loaded, and when i refresh the fragment then all the images are loaded because they are cached.

推荐答案

当您从Parse Cloud获取图像时,由于需要在Thread上进行时间解析,因此图像已加载但进入捕获内存,因此请始终使用Picasso Lib,因此请设置其使用的持有者为默认图片,如..

When u fetch image from Parse Cloud that a time parse work on Thread so image is loaded but into catch memory so always use Picasso Lib so set its please holder with default image like..

Picasso.with(mFragment.getActivity()).load(mCardList.get(i).getProfilePictureFiles().get(0).getUrl())                       .into(image).placeholder(R.drawable.ic_launcher);

这篇关于毕加索仅在BaseAdapter中加载一张图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 13:30