显示来自 assets/images 的图片库
displaying images Gallery from assets/images
我想显示图片库,但来自 "assets/images" 文件夹而不是 phone 存储。
喜欢这个:
问题不清楚,如果要从assets中加载单张图片,
那么你可以这样做。
//read image from asset
InputStream is = getAssets().open("image.jpg");
// create a drawable
Drawable drawable = Drawable.createFromStream(is, null);
//find reference to your imageview and set drawable
ImageView i=(ImageView)findViewById(R.id.image_id);
i.setImageDrawable(drawable);
我想显示图片库,但来自 "assets/images" 文件夹而不是 phone 存储。
喜欢这个:
问题不清楚,如果要从assets中加载单张图片, 那么你可以这样做。
//read image from asset
InputStream is = getAssets().open("image.jpg");
// create a drawable
Drawable drawable = Drawable.createFromStream(is, null);
//find reference to your imageview and set drawable
ImageView i=(ImageView)findViewById(R.id.image_id);
i.setImageDrawable(drawable);