我们可以使用android中的数据,使用Javascript在webview中显示它吗?

我们可以使用android中的数据,使用Javascript在webview中显示它吗?,java,javascript,php,android,mysql,Java,Javascript,Php,Android,Mysql,我使用MySql和PHP以及JSON解析从Web服务器获取数据。然后我将数据存储在arraylist中。现在我要做的是创建一个WebView,并将这些数据插入html字符串中,如下所示: htmlData = "<html>"+ "<head"+ "<title>Model Question</title>"+ "</head>"+ "<bo

我使用MySql和PHP以及JSON解析从Web服务器获取数据。然后我将数据存储在arraylist中。现在我要做的是创建一个WebView,并将这些数据插入html字符串中,如下所示:

htmlData = "<html>"+
            "<head"+
            "<title>Model Question</title>"+
            "</head>"+
            "<body>"+
            "The question of "+"English is :<br />"+getfromServer.get(0).getData()[0]+ 
            "<br /><form>"+
            "Option[0]"+"<input type='radio' name='c0' /><br />"+
            "Option[1]"+"<input type='radio' name='c1' /><br />"+
            "Option[2]"+"<input type='radio' name='c2' /><br />"+
            "Option[3]"+"<input type='radio' name='c3' /><br />"+
            "</form>"+
            "</body>"+
            "</html>";
现在我想执行循环,从数组列表中获取类型为Question_answer的每个对象,并将其放入字符串htmlData中,该字符串将进一步用作:

webview = (WebView) findViewById(R.id.wbvw);
    WebSettings websettings = webview.getSettings();
    websettings.setJavaScriptEnabled(true);



    webview.loadDataWithBaseURL("http://bar", htmlData,"text/html", "utf-8", "");
我们可以使用javascript吗?或者是他们的任何其他方式。 请帮忙。
提前谢谢

为什么不直接循环列表并使用
StringBuilder
构建html字符串呢?但是,要回答您的问题,可以在
WebView
中引用Javascript中的Java代码。请看这里的例子

webview = (WebView) findViewById(R.id.wbvw);
    WebSettings websettings = webview.getSettings();
    websettings.setJavaScriptEnabled(true);



    webview.loadDataWithBaseURL("http://bar", htmlData,"text/html", "utf-8", "");