android 获取assets下的图片

private Bitmap getImageFromAssetsFile(String filename) {
// picture_icon is folder in assets
		filename = "picture_icon/" + filename;
		Bitmap mBitmap = null;
		AssetManager mAssetManager = getResources().getAssets();
		try {
			InputStream mInputStream = mAssetManager.open(filename);
			mBitmap = BitmapFactory.decodeStream(mInputStream);
			mInputStream.close();
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			mBitmap = null;
		}
		return mBitmap;
	}

   

   

try {
			 String[] mIcon = mContext.getAssets().list("picture_icon");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

猜你喜欢

转载自bgj.iteye.com/blog/1968095