嘿伙计我有这个适配器类,我希望它将照片传递给gridview,我将照片的上下文和网址传递给构造函数,但似乎它们是null<任何人都可以告诉我这是什么问题?
public class MovieAdapter extends BaseAdapter {
private final String LOG_TAG = MovieAdapter.class.getSimpleName();
public final String urlBase = "http://image.tmdb.org/t/p/w185";
private final Context context;
private String[] urls;
public MovieAdapter(Context context, String[] urls) {
this.context = context;
this.urls = urls;
}
@Override
public int getCount() {
return urls.length;
}
@Override
public Object getItem(int position) {
return urls[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = new ImageView(context);
}
ImageView imageView = (ImageView) convertView;
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
String url = (String) getItem(position);
Log.e(LOG_TAG , "URL " + url);
Picasso.with(context).load(url).into(imageView);
return convertView;
}
}
答案 0 :(得分:0)