Its Simple to implement Just need javasript methods in your html to get value of html content. As Above your code some changes to be need.
public class htmldecoder extends Activity implements OnClickListener,TextWatcher
{
Button btsubmit; // this button in your xml file
WebView wvbrowser;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.htmldecoder);
btsubmit=(Button)findViewById(R.id.btsubmit);
btsubmit.setOnClickListener(this);
wvbrowser=(WebView)findViewById(R.id.wvbrowser);
wvbrowser.setWebViewClient(new HelloWebViewClient());
wvbrowser.getSettings().setJavaScriptEnabled(true);
wvbrowser.getSettings().setPluginsEnabled(true);
wvbrowser.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
MyJavaScriptInterface myinterface=new MyJavaScriptInterface();
wvbrowser.addJavascriptInterface(myinterface,"interface");
webView.loadUrl("file:///android_asset/simple.html"); //use one html file for //testing put your html file in assets. Make sure that you done JavaScript methods to get //values for html content in html file .
}
public void onClick(View v)
{
if(btsubmit==v)
{
webView.loadUrl("javascript:showalert()");// call javascript method.
//wvbr
}
}
final class MyJavaScriptInterface {
MyJavaScriptInterface() {
}
public void sendValueFromHtml(String value) {
System.out.println("Here is the value from html::"+value);
}
}
}
Your Javascript in html
<script type="text/javascript">
//<![CDATA[
var n1;
function callme(){
n1=document.getElementById("FacadeAL").value;
}
function showalert(){
window.interface.sendValueFromHtml(n1);// this method calling the method of interface which //you attached to html file in android. // & we called this showalert javasript method on //submmit buttton click of android.
}
//]]>
</script>
& Make sure you calling callme like below in html
<input name="FacadeAL" id="FacadeAL" type="text" size="5" onblur="callme()"/>
Hope this will help you.