2013-06-18 31 views
1

我无法让HighCharts在Android Web视图中呈现。这是在Android 4.0+HighCharts不会在Android + 4.x上的Android webview中加载

下面是我的html代码

<html lang="en" > 
<head> 
    <meta charset="utf-8" /> 
    <meta name="author" content="Script Tutorials" /> 
    <title>How to create active charts using Highcharts | Script Tutorials</title> 

    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> 
    <script src="http://code.highcharts.com/highcharts.js"></script> 

</head> 
<body> 
    <div id="chart_1" class="chart"></div> 
    <script type='text/javascript'> 
    $(document).ready(function() { 

// First chart initialization 
var chart1 = new Highcharts.Chart({ 
chart: { 
    renderTo: 'chart_1', 
    type: 'area', 
    height: 350, 
}, 
title: { 
    text: 'Tools developers plans to use to make html5 games (in %)' 
}, 
xAxis: { 
    categories: ['Processing.js', 'Impact.js', 'Other', 'Ease.js', 'Box2D.js', 'WebGL', 'DOM', 'CSS', 'Canvas', 'Javascript'] 
}, 
yAxis: { 
    title: { 
     text: 'Interviewed' 
    } 
}, 
series: [{ 
    name: 'Dev #1', 
    data: [5, 10, 20, 22, 25, 28, 30, 40, 80, 90] 
}, { 
    name: 'Dev #2', 
    data: [15, 15, 18, 40, 30, 25, 60, 60, 80, 70] 
}, { 
    name: 'Dev #3', 
    data: [1, 3, 6, 0, 50, 25, 50, 60, 30, 100] 
}] 
}); 

});</script> 
</body> 
</html> 

的,我读了资产目录中的HTML文件使用一个BufferedReader其转换成字符串,然后把它加载到使用

web视图
webview.loaddata(customHtml, "text/html", "UTF-8"); 
+0

你customHtml保持highcharts rendererd结构?或页面? –

回答

1

您是否在您的webview中启用了Javascript?如果没有,只是加入这一行你onCreate方法:

webview.getSettings().setJavaScriptEnabled(true); 

其中 “网页视图” 是:

WebView webview = (WebView)findViewById(R.id.my_webview); 
+0

不适合我 – Aamirkhan