2015-04-05 27 views
7

我嘗試將我從我的事情帳戶中獲取的iframe圖表放入。在Android應用上放置iframe

這是我需要把字符串(已經我從thingspeak了):

<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="http://api.thingspeak.com/channels/31592/charts/1?width=450&height=260&results=60&dynamic=true" ></iframe> 

這是我用我的活動:

WebView webview; 
    webview = (WebView) findViewById(R.id.webview); 
    webview.getSettings().setJavaScriptEnabled(true); 
    webview.loadData(); 

我嘗試沒有成功,把我的iframe 「loadData」函數中的字符串。

得益於幫手;)

回答

16

您可以創建一個字符串與HTML:

String html = "<iframe width=\"450\" height=\"260\" style=\"border: 1px solid #cccccc;\" src=\"http://api.thingspeak.com/channels/31592/charts/1?width=450&height=260&results=60&dynamic=true\" ></iframe>"; 

,然後調用方法loadData():

webview.loadData(html, "text/html", null); 

Click Here for reference

+1

感謝它的工作! – Yossi 2015-04-06 05:47:17

+1

請標記爲正確答案 – Arlind 2015-04-06 08:37:06