을 초과와 이미지 갤러리에 앞뒤로 내 응용 프로그램 충돌을 시간의 무리를 스크롤 할 때 상단 하나는 고해상도/당김 폴더에있는 이미지의 미리 정의 된 그룹에서 선택 될 것입니다안드로이드 사용자 정의 갤러리 위젯 java.lang.OutOfMemoryError와 함께 충돌 :</p> <p>java.lang.OutOfMemoryError와 : 비트 맵 크기의 비트 맵 크기가 VM 예산
- : VM 예산
나는 수직으로 두 개의 이미지를 표시하는 갤러리를 필요 초과합니다.
- 하단 이미지는이 특정 이미지에 올바른 답변 (게임의 점수 페이지 제출) 또는 잘못 표시되면 줄이 표시된 빨간색 원으로 표시되면 녹색 체크 표시가됩니다.
public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground; private Context mContext; public ImageAdapter(Context c) { mContext = c; TypedArray attr = mContext.obtainStyledAttributes(R.styleable.SubmitScoreGallery); mGalleryItemBackground = attr.getResourceId( R.styleable.SubmitScoreGallery_android_galleryItemBackground, 0); attr.recycle(); } @Override public int getCount() { return numQuestions; } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { //Setup a LinearLayout to display the second image LinearLayout lLayout = new LinearLayout(this.mContext); lLayout.setOrientation(LinearLayout.VERTICAL); //Create the ImageView ImageView imageView = new ImageView(this.mContext); imageView.setImageResource(imageList.get(randOrder.get(position))); imageView.setLayoutParams(new Gallery.LayoutParams(gDispW, gDispH)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setBackgroundResource(mGalleryItemBackground); lLayout.addView(imageView); //Create the right/wrong image ImageView imageViewBottom = new ImageView(lLayout.getContext()); if (score.getScoreAtIndex(position)== 1){ imageViewBottom.setImageResource(R.drawable.green_checkmark); } else{ imageViewBottom.setImageResource(R.drawable.incorrect_circle); } imageViewBottom.setLayoutParams(new Gallery.LayoutParams(gDispW, gDispH)); imageViewBottom.setPadding(gDispW/3, 0, gDispW/3, gDispH/2); imageViewBottom.setScaleType(ImageView.ScaleType.CENTER_INSIDE); //imageViewBottom.setScaleType(ImageView.ScaleType.CENTER_INSIDE); lLayout.addView(imageViewBottom); return lLayout; } }
randOrder는 이미지
갤러리 5, 10 또는 15의 이미지를 보유 순서를 보유하는 배열이다 : 여기
는 BaseAdapter을 연장 내 코드 사용자가 선택한 질문 수에 따라
15 개의 이미지와 일관되게 충돌이 발생할 수 있습니다.
더 좋은 방법이 있나요?
내가 뭘 잘못하고 있니?
는 이미지 뷰를 매번 작성의 getView 방법에닐
imageView, lLayout 및 imageViewBottom에 대해이 작업을 시도했지만 여전히 충돌합니다. –
리샘플링 비트 맵을 사용해 보셨습니까?이 질문을 확인하십시오 : http://stackoverflow.com/questions/3331527/android-resize-a-large-bitmap-file-to-scaled-output-file –