[팁] [안드로이드] assets 폴더의 이미지 불러와 Imageview 로딩 방법
assets 폴더의 이미지 불러오는 방식
1. 비트맵 리턴 메소드 생성
public Bitmap loadBitmap(String urlStr) {
Bitmap bitmap = null;
AssetManager mngr = getResources().getAssets();
try{
InputStream is = mngr.open(urlStr);
bitmap = BitmapFactory.decodeStream(is);
}catch(Exception e){
Log.e(TAG, "loadDrawable exception" + e.toString());
}
return bitmap;
}
2. ImageView 인스턴스인 graphIv에 다음처럼 세팅합니다.
graphIv = (ImageView)findViewById(R.id.imageView);
Bitmap bitmap = loadBitmap(graphUri);
graphIv.setImageBitmap(bitmap);
▼ 이 게시물의 댓글 + 0
* 엮인글 + 0