由网友(可念不可说)分享简介:我希望有一个线图我与谷歌图表API来image.How转换,应该怎么办?我没有在网络上任何可以帮助找到。I want to convert a line graph I made with google charts api to image.How should I do?I didn't found on the...
我希望有一个线图我与谷歌图表API来image.How转换,应该怎么办?我没有在网络上任何可以帮助找到。
I want to convert a line graph I made with google charts api to image.How should I do?I didn't found on the net anything that can help.
推荐答案
试图将谷歌图表转换为位图,并设置为你的形象到您的ImageView。
try to convert your google chart as bitmap and set as your image to your imageview.
为前:
Bitmap bitmap = loadChart("your google image url");
和loadChart方法
and loadChart method is
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;
}
最后,你可以通过以下code将位图图像视图的背景。
And finally you can set your bitmap as your image view background by using following code.
image.setImageBitmap(bitmap);
试试看。 我希望这会帮助你。
Try it. I hope this will help you.
相关推荐
最新文章