그래서 SD 카드에서 Android Gallery로 이미지를로드하고 있습니다. 메뉴를 누른 다음 선택하고 갤러리 아래의 코드를 통해 삽입됩니다. 문제는 약 5 또는 6 이미지가 메모리 부족 오류가 발생했습니다. 01-04 18 : 10 : 35.246 : ERROR/AndroidRuntime (10220) : java.lang.OutOfMemoryError : 비트 맵 크기가 VM 예산을 초과합니다. 이 문제를 해결 하시겠습니까?Android Java Gallery 메모리 부족 오류
public class ImageAdapter extends BaseAdapter{
int mGalleryItemBackground;
public ImageAdapter(Context c) {
mContext = c;
TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
mGalleryItemBackground = typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);
typArray.recycle();
}
public int getCount(){
return mUrls.length;
}
public Object getItem(int position){
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent){
ImageView i = new ImageView(mContext);
i.setImageURI(mUrls[position]);
i.setScaleType(ImageView.ScaleType.FIT_XY);
i.setLayoutParams(new Gallery.LayoutParams(120, 120));
return i;
}
private Context mContext;
}
재활용 방법을 제거해보십시오. 그것은 나를 위해이 문제를 해결했다. 그것은 최선의 관행인지는 모르겠다. – GSree
나를 위해 작동하지 않았다 – Paul