我想知道为什么我的图片没有出现在封面上。有任何想法吗?这是基于 android 画廊应用程序的封面流。它从 R.drawable 获取图像作为源。我将其更改为从 SD 卡中取出图像。而且我不知道如何使用作者推荐的代码。
这是有关如何从外部源获取代码的原始作者示例:
//Use this code if you want to load from resources
ImageView i = new ImageView(mContext);
i.setImageResource(mImageIds[position]);
i.setLayoutParams(new CoverFlow.LayoutParams(130, 130));
i.setScaleType(ImageView.ScaleType.MATRIX);
return i;
这就是我的尝试方法:首先注释掉 R.drawable 引用的代码;
public class ImageAdapter extends BaseAdapter {
int mGalleryItemBackground;
private Context mContext;
private FileInputStream fis;
private Integer[] mImageIds = {
// R.drawable.pic01,
// R.drawable.pic02,
// R.drawable.pic03,
// R.drawable.pic04,
// R.drawable.pic05,
// R.drawable.pic06,
// R.drawable.pic07,
// R.drawable.pic08,
// R.drawable.pic09
};
private ImageView[] mImages;
public View getView(int position, View convertView, ViewGroup parent) {
ImageView i = new ImageView(mContext.getApplicationContext());
imagecursor.moveToPosition(position);
int id = imagecursor.getInt(image_column_index);
i.setImageURIUri.withAppendedPathMediaStore.Images.Media.EXTERNAL_CONTENT_URI, ""+ id));
i.setLayoutParams(new CoverFlow.LayoutParams(130, 130));
i.setScaleType(ImageView.ScaleType.MATRIX);
return i;
//return mImages[position];
}