Picasso 只在 BaseAdapter 中加载一张图像
Picasso only loading one image in a BaseAdapter
在 BaseAdapter 的 getView() 中,我使用 URL 和 Picasso 将图像加载到 ImageView 中。不幸的是,只有一张图片正在加载。这是 getView() 代码:
@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 被加载,当我刷新片段时所有图像都被加载,因为它们被缓存。
当你从 Parse Cloud 获取图像时,时间解析在 Thread 上工作,所以图像被加载但进入捕获内存,所以总是使用 Picasso Lib,所以请将其设置为默认图像,如..
Picasso.with(mFragment.getActivity()).load(mCardList.get(i).getProfilePictureFiles().get(0).getUrl()) .into(image).placeholder(R.drawable.ic_launcher);
在 BaseAdapter 的 getView() 中,我使用 URL 和 Picasso 将图像加载到 ImageView 中。不幸的是,只有一张图片正在加载。这是 getView() 代码:
@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 被加载,当我刷新片段时所有图像都被加载,因为它们被缓存。
当你从 Parse Cloud 获取图像时,时间解析在 Thread 上工作,所以图像被加载但进入捕获内存,所以总是使用 Picasso Lib,所以请将其设置为默认图像,如..
Picasso.with(mFragment.getActivity()).load(mCardList.get(i).getProfilePictureFiles().get(0).getUrl()) .into(image).placeholder(R.drawable.ic_launcher);