您好,因为我是Android开发的新手,并且对滚动视图不太了解,现在我面临着关于gridView滚动的问题,我的网格视图中有20个图像,当我尝试向下滚动查看时它没有正确滚动的图像会减慢速度,有时它会说应用程序已停止响应并崩溃。任何人都可以帮助我使滚动顺利并解决这个问题。 这是我的#34; ImageAdapter"
的代码public class ImageAdapter extends BaseAdapter{
private Context mContext;
private int[] mThumbsIda={
R.drawable.sample_1,
R.drawable.sample_2,
R.drawable.sample_3,
R.drawable.sample_4,
R.drawable.sample_5,
R.drawable.sample_6,
R.drawable.sample_7,
R.drawable.sample_8,
R.drawable.sample_9,
R.drawable.sample_10,
R.drawable.sample_11,
R.drawable.sample_12,
R.drawable.sample_13,
R.drawable.sample_14,
R.drawable.sample_15,
R.drawable.sample_16,
R.drawable.sample_17,
R.drawable.sample_18,
R.drawable.sample_19,
R.drawable.sample_20,
R.drawable.sample_21,
R.drawable.sample_22,
R.drawable.sample_23
};
public ImageAdapter(Context c){
mContext = c;
}
public int getCount(){
return mThumbsIda.length;
}
public Object getItem(int position){
return null;
}
public long getItemId(int position){
return 0;
}
public View getView(int position, View convertView, ViewGroup parent){
ImageView imageView;
if (convertView == null) {
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,385));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(5,5,5,5);
}
else{
imageView = (ImageView) convertView;
}
imageView.setImageResource(mThumbsIda[position]);
return imageView;
}
}