2010-12-15 3 views

답변

11

를 사용하여 코드 다음은이

URL url = new URL(imageUrl); 
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 

InputStream is = connection.getInputStream(); 
Bitmap img = BitmapFactory.decodeStream(is); 

imageView.setImageBitmap(img); 
5

이미지를 읽어 주셔서 도움이 될 것입니다. 그러나 UI 스레 드에서이 작업을 수행하면 UI가 중단된다는 것을 기억하십시오. 항상 새 스레드를 열고 해당 스레드에서 이미지를로드해야합니다. 따라서 앱은 항상 반응 적입니다.

InputStream is = null; 
BufferedInputStream bis = null; 
Bitmap bmp = null; 
try { 
    URLConnection conn = url.openConnection(); 
    conn.connect(); 
    is = conn.getInputStream(); 
    bis = new BufferedInputStream(is); 
    bmp = BitmapFactory.decodeStream(bis); 
} catch (MalformedURLException e) { 

} catch (IOException e) { 

} finally { 
    try { 
     is.close(); 
     bis.close(); 
    } catch (IOException e) { 

    } 
} 
imageView.setImageBitmap(bmp); 
0

그것은 이미 this link

이 참조에서 논의 된, 그것은

행복한 코딩 되세요 .. 결실이 될 것입니다 ...! 그것은 것

관련 문제