我正在使用滑动库在网格视图中显示图像但是当我在网格视图中滚动图像时,图像每次都会动态变化。在位置上有错误的图像。 这是我的适配器代码:
public class GridViewAdapter extends ArrayAdapter {
private Context context;
private LayoutInflater inflater;
private String[] imageUrls;
public ImageView image;
public TextView text;
public GridViewAdapter(Context context, String[] imageUrls) {
super(context, R.layout.image_grid_layout, imageUrls);
this.context = context;
this.imageUrls = imageUrls;
inflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (null == convertView) {
convertView = inflater.inflate(R.layout.image_grid_layout, parent, false);
image = (ImageView) convertView.findViewById(R.id.image);
text = (TextView) convertView.findViewById(R.id.text);
}
Glide
.with(context)
.load(imageUrls[position])
.into(image);
return convertView;
}
}