0
我在我的android应用程序中有一个画廊,当我点击图库项目时我想显示图像和网格视图。我完成时,我只有三个图像在画廊,并点击它正确显示。但现在我有7个图像在画廊和每个画廊项目有四个图像来显示画廊。在这我只使用drwwable图像数组。在图库项目中点击我如何显示图像视图和网格视图?
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;
}
请提供任何建议。提前致谢。 我有这样
经典的Android问题:) 检查了这一点: http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-在-列表视图 – Slickelito 2012-07-23 12:49:54