In the Chart Wizard, select your chart, enter data, lets the wizard generate the chart, copy the link of "Paste link in email or IM" to embeddedWeb in the code.
Noted: In order to load the generated charts, permission of "android.permission.INTERNET" is need.
package com.AndroidEmbeddedWebView;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class AndroidEmbeddedWebViewActivity extends Activity {
WebView embeddedWebView;
String embeddedWeb = "http://chart.apis.google.com/chart?chxl=0:|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec&chxt=x,y&chs=300x300&cht=r&chco=FF0000&chd=t:63,64,67,73,77,81,85,86,85,81,74,67,63&chls=2,4,0&chm=B,FF000080,0,0,0";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
embeddedWebView = (WebView)findViewById(R.id.embeddedwebview);
embeddedWebView.loadUrl(embeddedWeb);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<WebView
android:id="@+id/embeddedwebview"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_gravity="center"
/>
</LinearLayout>
0 Response to "Embeded Google Chart in WebView"
Posting Komentar