Java Android Picasso不会将所有图像加载到imageview
我正在尝试将图像加载到ListAdapter中的imageview。但是,当我将10个缩略图传递给listAdapter并在imageview中设置它们时,imageview中只有1个或没有一个可见。据我从文档中了解,我不需要使用任何asyntask,因为毕加索图书馆已经在使用asyntask了。你能帮我处理这个问题吗 //像这样调用CustumListAdapterJava Android Picasso不会将所有图像加载到imageview,java,android,list,imageview,picasso,Java,Android,List,Imageview,Picasso,我正在尝试将图像加载到ListAdapter中的imageview。但是,当我将10个缩略图传递给listAdapter并在imageview中设置它们时,imageview中只有1个或没有一个可见。据我从文档中了解,我不需要使用任何asyntask,因为毕加索图书馆已经在使用asyntask了。你能帮我处理这个问题吗 //像这样调用CustumListAdapter CustomListAdapter customListAdapter = new CustomListAdapter(this
CustomListAdapter customListAdapter = new CustomListAdapter(this, resultArrayList);
listView = (ListView) findViewById(R.id.listview_score);
listView.setAdapter(customListAdapter)
//这是我的CustomListAdapter类
public class CustomListAdapter extends ArrayAdapter<String> {
private ArrayList<String> resultContent;
//private Integer[] imageid;
private Activity context;
public CustomListAdapter(Activity context, ArrayList<String> resultContent) {
super(context, R.layout.activity_ident_result2, resultContent);
this.context = context;
this.resultContent = resultContent;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.activity_ident_result2, null, true);
if (position % 2 == 0) {
TextView textViewName = (TextView) listViewItem.findViewById(R.id.textView_score);
textViewName.setText(resultContent.get(position));
ImageView imageView = (ImageView) listViewItem.findViewById(R.id.imageView_score);
//imageView.setImageBitmap(IdentResultActivity.splittedBitmaps.get(position + 1));
Picasso.with(this.context).load(resultContent.get(position + 1)).into(imageView);
}
return listViewItem;
}
}
我相信
充气机.inflate
的参数应该是(R.layout.activity_ident_result2,parent,false)
您需要创建循环,将每个图像添加到[]中,然后显示它。由于您发布的代码u只添加了一个图像。但是当您滚动列表时,它是否显示正确的图像?无论我滚动与否,所有图像都是空的(有时显示一个图像)。您是否检查了JSON响应?另外,请检查图像的大小。可能是因为json中的图像更大。所以使用毕加索加载图像需要时间。@peeyuspathak我发现问题出在服务器端HTTP
请求指向HTTPS
,看起来picasso
与转发不兼容。
<ImageView
android:layout_width="75dp"
android:layout_height="75dp"
android:id="@+id/imageView_score" />