2011-01-07 67 views

回答

0

如果您使用尝试图库视图与资产的文件夹下,如/assets/images/myimage.jpg

String imagePath = "images/myimage.jpg" 

Bitmap bmp = null; 
try{ 
    InputStream is = getAssets().open(imagePath);   
    bmp = BitmapFactory.decodeStream(is); 
} 
catch(Exception exception) 
{ 
    bmp = BitmapFactory.decodeResource(getResources(), R.drawable.icon_grey_box); 
} 
((ImageView)findViewById(R.id.myimage)).setScaleType(ImageView.ScaleType.CENTER_CROP); 
((ImageView)findViewById(R.id.myimage)).setImageBitmap(bmp); 

刚还认为,和有一个数据提供程序,那么你可能能够将图像格式使用

文件路径:// MNT/SD卡/ imageassets/

我觉得还有一种方法来访问您的APK文件夹的资产,使用URI路径,类似于

“android.resource:// [package]/[res id]”

这解释得很好。

http://androidbook.blogspot.com/2009/08/referring-to-android-resources-using.html

+0

感谢您的启发 – ingsaurabh 2011-01-10 05:49:27