Android assets 폴 더 의 그림 자원 가 져 오기

이 방법 은 도구 클래스 에서 직접 사용 할 수 있 습 니 다:

  
  
  
  
  1.  *  Assets  
  2.  * @param context 
  3.  * @param fileName   
  4.  * @return 
  5.  */ 
  6. public static Bitmap getImageFromAssetsFile(Context context, String fileName) {   
  7.     Bitmap image = null;   
  8.     AssetManager am = context.getResources().getAssets();   
  9.     try {   
  10.         InputStream is = am.open(fileName);   
  11.         image = BitmapFactory.decodeStream(is);   
  12.         is.close();   
  13.     } catch (IOException e) {   
  14.         e.printStackTrace();   
  15.     }   
  16.     return image;   

본 고 는'꿈 을 겨울잠 에 자게 하 는'블 로그 에서 나 온 것 으로 전 재 를 사절 합 니 다!

좋은 웹페이지 즐겨찾기