如何在.java类的布局.xml类中使用方法?

时间:2013-04-08 09:32:19

标签: android

我试图放置多个图像使模拟器崩溃时出现问题。一个解决方案是这个 您将图像放在Assets文件夹而不是Drawable文件夹中,但我不知道如何返回此方法并将其作为ImageView的src图像

public static Drawable getAssetImage(Context context, String filename) throws IOException {
AssetManager assets = context.getResources().getAssets();
InputStream buffer = new BufferedInputStream((assets.open("drawable/" + filename + ".png")));
Bitmap bitmap = BitmapFactory.decodeStream(buffer);
return new BitmapDrawable(bitmap);
}

0 个答案:

没有答案