2013-04-06 66 views

回答

2

嘗試將您的谷歌圖表轉換爲位圖並設置爲您的圖像到您的圖像瀏覽。

爲前:

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 2013-04-06 12:38:49