ギャラリーを作成してギャラリーを作成したアプリケーションを1つ作成しました。ズームビューで選択した画像を表示しています... 2つ以上の画像があると、それとは画像をクリックしてください..私はこれで助けを必要と...ギャラリーに強制終了エラーが表示されます
自分のアプリケーションのコードです:
img = (ImageView) findViewById(R.id.GalleryView);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
Gallery g = (Gallery) findViewById(R.id.gallery);
// set gallery to left side
MarginLayoutParams mlp = (MarginLayoutParams) g.getLayoutParams();
mlp.setMargins((int)-(metrics.widthPixels/2 + 35), mlp.topMargin,mlp.rightMargin, mlp.bottomMargin);
imageAdapter = new ImageAdapter(this,imgarr);
g.setAdapter(imageAdapter);
if(imgarr.length > 1)
{
img.setImageURI(Uri.parse(imgarr[0]));
}
g.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
dialog = ProgressDialog.show(ImageGallery.this,
"Loading Image", "Please wait...", true);
img.setImageURI(Uri.parse(imgarr[position]));
dialog.dismiss();
}
});
ImageAdapter class:
public class ImageAdapter extends BaseAdapter {
int mGalleryItemBackground;
private Context mContext;
String[] imgArray;
public ImageAdapter(Context c,String[] imgArray) {
mContext = c;
TypedArray attr = mContext
.obtainStyledAttributes(R.styleable.ImageGallery);
mGalleryItemBackground = attr.getResourceId(
R.styleable.ImageGallery_android_galleryItemBackground, 0);
this.imgArray = imgArray;
attr.recycle();
}
public int getCount() {
return imgArray.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);
//Toast.makeText(getApplicationContext(), "Image path from gallery : " + imgArray[position],
//Toast.LENGTH_SHORT).show();
//Bitmap bitmap = BitmapFactory.decodeFile(imgArray[position]);
Log.d("cursor lengh :", "" +imgArray[position]);
//i.setImageBitmap(bitmap);
i.setImageURI(Uri.parse(imgArray[position]));
i.setLayoutParams(new Gallery.LayoutParams(80, 70));
i.setScaleType(ImageView.ScaleType.FIT_CENTER);
i.setBackgroundResource(mGalleryItemBackground);
return i;
}
}
私はこれらのエラーを持っている:
ここでlogcat画像を貼り付ける代わりに、logcatログ自体を貼り付けることができますか?大いに役立つでしょう。可視性の問題。私は 'OutOfMemoryError:ビットマップサイズがVM予算を超えています.'しか見ることができません。これはあなたのビットマップが巨大であることを意味します。 – Ghost