2013-06-18 32 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