2013-04-06 2 views

답변

2

Google 차트를 비트 맵으로 변환하여 이미지 뷰로 설정하십시오. 전 대한

:

Bitmap bitmap = loadChart("your google image url"); 

및 loadChart 방법은

private Bitmap loadChart(String urlRqs) { 
     Bitmap bm = null; 
     InputStream inputStream = null; 

     try { 
      inputStream = OpenHttpConnection(urlRqs); 
      bm = BitmapFactory.decodeStream(inputStream); 
      inputStream.close(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 

     return bm; 
    } 

OpenHttpConnection

private InputStream OpenHttpConnection(String strURL) throws IOException { 

     InputStream is = null; 
      URL url = new URL(strURL); 
      URLConnection urlConnection = url.openConnection(); 

      try{ 
      HttpURLConnection httpConn = (HttpURLConnection)urlConnection; 
      httpConn.setRequestMethod("GET"); 
      httpConn.connect(); 

      if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) { 
      is = httpConn.getInputStream(); 
      } 
      }catch (Exception ex){ 
       Log.e("###","",ex); 
      } 

     return is; 
    } 

입니다 그리고 마지막으로 당신은 다음과 같은 사용하여 이미지보기 배경으로 비트 맵을 설정할 수 있습니다 암호.

image.setImageBitmap(bitmap); 

사용해보기. 도움이되기를 바랍니다.

+0

답변 해 주셔서 감사합니다. 매력처럼 일했다. – user2137817

관련 문제