I have fetched data from Web Server using MySql and PHP with JSON parsing. And then I have stored the data in the arraylist. Now what I want to do is to create a WebView and insert those datas in html string as given below:
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>";
here the getfromServer is the ArrayList of type Question_answer which is defined as:
package com.example.mcahelper;
public class Question_answer {
private String Question,Options[] = new String[4];
public void setData(String...datas){
Question = datas[0];
Options[0]=datas[1];
Options[1]=datas[2];
Options[2]=datas[3];
Options[3]=datas[4];
}
public String[] getData(){
String datas[]= new String[5];
datas[0] = Question;
datas[1]=Options[0];
datas[2]=Options[1];
datas[3]=Options[2];
datas[4]=Options[3];
return datas;
}
}
Now i want to execute the loop to get every object of type Question_answer from the array list and put it in the string htmlData which will be further used as:
webview = (WebView) findViewById(R.id.wbvw);
WebSettings websettings = webview.getSettings();
websettings.setJavaScriptEnabled(true);
webview.loadDataWithBaseURL("http://bar", htmlData,"text/html", "utf-8", "");
Can we use javascript or is their any other way. Please help. Thanks in advance!