내 장치에서 이미지를로드하고 격자보기로 채우는 중입니다. 이 목적으로 비동기 작업을 사용하고 있는데도 내 눈금보기 스크롤이 지연됩니다. 어떤 도움이미지를 표시 할 때 지연 격자보기
이 내 어댑터
public class ImageAdapter extends BaseAdapter {
Context c;
LayoutInflater inflater;
GridView gv;
ArrayList<File> list;
ImageAdapter(Context c, GridView gv, ArrayList<File> list) {
this.gv = gv;
this.list = list;
this.c = c;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int i) {
return list.get(i);
}
@Override
public long getItemId(int i) {
return list.size();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v;
if (convertView == null) {
inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.single_grid, parent, false);
} else {
v = convertView;
}
String path = list.get(position).getPath();
Bitmap bitmap = BitmapFactory.decodeFile(path);
Bitmap bitmap2 = scaleBitmap(bitmap, 100, 100);
ImageView iv = (ImageView) v.findViewById(R.id.imageView);
iv.setImageBitmap(bitmap2);
return v;
}
public static Bitmap scaleBitmap(Bitmap bitmapToScale, float newWidth, float newHeight) {
if (bitmapToScale == null)
return null;
//get the original width and height
int width = bitmapToScale.getWidth();
int height = bitmapToScale.getHeight();
// create a matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(newWidth/width, newHeight/height);
// recreate the new Bitmap and set it back
return Bitmap.createBitmap(bitmapToScale, 0, 0, bitmapToScale.getWidth(), bitmapToScale.getHeight(), matrix, true);
}
} 당신은 기본 응용 프로그램 스레드에서 이미지를로드