我的資產文件夾中有一個圖像(welcome_image.jpg)。並使用此代碼從資產中讀取。從資產文件夾中讀取圖像文件
Bitmap bit = null;
String url = "/assets/welcome_image.jpg";
bit = BitmapFactory.decodeFile(url);
但位是空和投擲誤差
03-26 16:42:15.303: D/Image exisits....(21547): Image url : /assets/welcome_image.jpg
03-26 16:44:39.853: E/BitmapFactory(21547): Unable to decode stream: java.io.FileNotFoundException: /assets/welcome_image.jpg: open failed: ENOENT (No such file or directory)
請告訴我如何實現這一目標。
試試這個 InputStream ims = getAssets()。open(「welcome_image.jpg」); //載入圖像爲可繪製 Drawable d = Drawable.createFromStream(ims,null); – 2013-03-26 11:24:43