【基础篇】Android中获取Drawable的方法

public static Drawable getDrawable(Context context,String filename)
{
BitmapDrawable drawable=null;
InputStream is;
try {
is = context.getAssets().open(ConstantValue.ASSETS_RES_PATH+filename);
Bitmap bitmap = BitmapFactory.decodeStream(is);
drawable = new BitmapDrawable(context.getResources(), bitmap);

is.close();
} catch (IOException e) {

e.printStackTrace();
}


return drawable;
}

posted on 2013-09-29 14:09  土鳖程序员  阅读(1855)  评论(0编辑  收藏  举报

导航