Android 如何在同一活动中显示galleryview、imageview和gridview

Android 如何在同一活动中显示galleryview、imageview和gridview,android,gridview,imageview,gallery,Android,Gridview,Imageview,Gallery,我在android应用程序中有一个图库,当我点击图库项目时,我想显示图像和网格视图。当我的图库中只有三张图片,并且在单击时正确显示时,我就这样做了。但现在我在gallery中有七个图像,每个gallery项有四个图像要显示gallery。在这里,我只使用Drwable图像数组。在这一次,我得到了一个例外,Java.lang.OutOfMemory,我使用下面的代码 public ImageThemeAdapter(Context c, Integer[] mImageI

我在android应用程序中有一个图库,当我点击图库项目时,我想显示图像和网格视图。当我的图库中只有三张图片,并且在单击时正确显示时,我就这样做了。但现在我在gallery中有七个图像,每个gallery项有四个图像要显示gallery。在这里,我只使用Drwable图像数组。在这一次,我得到了一个例外,Java.lang.OutOfMemory,我使用下面的代码

             public ImageThemeAdapter(Context c, Integer[] mImageIds) {
 imagesId=mImageIds;
 bitmap=new Bitmap[imagesId.length];
 mContext = c;
 TypedArray ta=obtainStyledAttributes(R.styleable.Gallery1);
    imageBackground=ta.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 1);
    ta.recycle();
    for (int i = 0; i <imagesId.length; i++) {
       bitmap[i]=BitmapFactory.decodeResource(mContext.getResources(),imagesId[i]);
    }
}

public int getCount() {
    return bitmap.length;
}

public Object getItem(int position) {
    return bitmap[position];  
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {   

    ImageView i = new ImageView(mContext);

    i.setImageBitmap(bitmap[position]);
    i.setScaleType(ImageView.ScaleType.FIT_XY);
    i.setLayoutParams(new Gallery.LayoutParams(130, 120));
   // i.setLayoutParams(new Gallery.LayoutParams((ScreenWidth*80)/100, android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
    i.setBackgroundResource(imageBackground);
    return i;   
}
还有我的屏幕截图


请提前提供任何建议,谢谢。

您也可以使用水平滚动视图而不是gallery您也可以使用水平滚动视图而不是gallery