2013-04-06 63 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