@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Main();
}
public void Main()
{
_linearLayout = new LinearLayout(this);
_webview = new WebView(this);
_linearLayout.addView(_webview, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
setContentView(_linearLayout);
_webview.getSettings().setJavaScriptEnabled(true);
_webview.getSettings().setPluginsEnabled(true);
_webview.getSettings().setAllowFileAccess(true);
_webview.setWebChromeClient(new WebChromeClient());
_webview.addJavascriptInterface(this, "Question");
_webview.loadData(GetHTML(), "text/html", "utf-8");
}
public String GetHTML()
{
String HTML = ""
+ "<HTML>"
+ "<HEAD>"
+ "<TITLE>Radio Button onClick Handler</TITLE>"
+ "<SCRIPT LANGUAGE=\"JavaScript\">"
+"function function1(colors) {"
+"var col = (colors.options[colors.selectedIndex].value);"
+" if (col) {"
+" document.bgColor = col;"
+" } "
+"</script>"
+ "</HEAD>"
+ "<BODY>"
+"<form>"
+"<b> Hello </b>"
//+"<select name=\"colors\" onChange=\"window.Question.function1(this);\">"
+"<select name=\"colors\" onChange=\"window.Question.OnJsClick_SelectedItem(' string value');\">"
+"<option value=\"white\" selected>White</option>"
+ "<option value=\"cyan\">Cyan</option>"
+ "<option value=\"ivory\">Ivory</option>"
+ "<option id=\"myO\" value=\"blue\">Blue</option>"
+"</select>"
+"</form>"
+ "</BODY>"
+ "</HTML>";
return HTML;
}
public void OnJsClick_SelectedItem(final String str)
{
mHandler.post(new Runnable()
{
//@Override
public void run()
{
getValue(str);
}
});
}
public String getValue(String str)
{
_webview.loadUrl("javascript:function1(colors)");
Toast.makeText(this, "Under getValue " + str, Toast.LENGTH_SHORT).show();
return str;
}
}
Please help me out.