我想在GridView中显示来自URL的一些图像,我记录了一切,看起来它的工作原理(适配器已加载,Picasso Callback记录成功,URL正确等)但图像未显示。我不知道我做错了什么,我确信这对你来说很明显,但我盯着这几个小时没什么。
public class GridImageAdapter extends ArrayAdapter<MovieObj> {
Context mContext;
private static final String LOG_TAG = GridImageAdapter.class.getSimpleName();
public GridImageAdapter(Activity context, List<MovieObj> movieObjects){
super(context, 0, movieObjects);
mContext = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MovieObj currentMovie = getItem(position);
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.grid_item_movie_poster, parent, false);
}
ImageView imageView = (ImageView) convertView.findViewById(R.id.grid_item_image);
String posterId = currentMovie.getPosterId();
String posterUrl = "http://image.tmdb.org/t/p/w185" + posterId;
Picasso.with(mContext).load(posterUrl).placeholder(R.drawable.placeholder_ic).error(R.drawable.placeholder_ic).into(imageView, new Callback() {
@Override
public void onSuccess() {
Log.v(LOG_TAG, "Image Loaded");
}
@Override
public void onError() {
Log.v(LOG_TAG, "Does not load");
}
});
Log.v(LOG_TAG, posterUrl);
return convertView;
}
}
在片段中: