问题描述
我正在使用此库构建类似Tinder的Android应用程序: https://github.com/Diolor/Swipecards 和Picasso进行图像加载.除了列表的第一个视图之外,其他所有内容都可以正常运行.尽管文本正确,但未显示图像.
I am building a Tinder-like Android app with this library : https://github.com/Diolor/Swipecards and Picasso for image loading. Everything works fine, except the first view of the list. The image is not displayed, although the text is correct.
视图存储在ArrayAdapter的自定义子类中.这是代码:
Views are stored in a custom subclass of ArrayAdapter. Here is the code:
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
switch (getItemViewType(position)) {
case TYPE_MOVIE:
ViewHolderMovie holder;
if (convertView == null) {
holder = new ViewHolderMovie();
convertView = inflater.inflate(R.layout.movie_card, parent, false);
holder.movieCover = (ImageView)convertView.findViewById(R.id.movieCover);
holder.movieTitle = (TextView)convertView.findViewById(R.id.movieTitle);
holder.movieGenre = (TextView)convertView.findViewById(R.id.movieGenre);
convertView.setTag(holder);
} else {
holder = (ViewHolderMovie) convertView.getTag();
}
Movie movie = (Movie) data.get(position);
Picasso.with(convertView.getContext())
.load(movie.imagePath)
.resize(500, 500)
.into(holder.movieCover); // this doesn't work for the first view
holder.movieTitle.setText(movie.title);
holder.movieGenre.setText("Film au cinéma ("+movie.genre+")");
return convertView;
}
return null;
}
请问您有个主意吗?
推荐答案
检查图像的URL路径,特别是斜杠"/".当'/'在imageurl路径中有两次时,Picasso不会显示ArrayAdapter的第一张图像.但是当您滚动Gridview或Listview时,它确实显示了
Check Your image URL path ,especially slash '/'.Picasso don't show first image of ArrayAdapter when '/' has twice in your imageurl path.But it show truly when you scroll Gridview or Listview
这篇关于毕加索未加载ArrayAdapter的第一张图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!