Bitmap bitmap = Utils.getLoacalBitmapByAssets(activity, "a.png");
if(bitmap!=null){
rl2.setBackgroundDrawable(BitmapCache.getDrawable(activity, "a.png"));
}
public static Bitmap getLoacalBitmapByAssets(Context c, String url) {
Bitmap bitmap = null;
InputStream in = null;
try {
in = c.getResources().getAssets().open(url);
bitmap = BitmapFactory.decodeStream(in);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return bitmap;
}
Android判断asset中是否存在某个文件
最新推荐文章于 2024-07-22 17:24:13 发布