Friday, May 11, 2012

[android-developers] javascript in webview on android 2.3 fires only once

I've got the following test.htm in the assets directory:
 

<input type="checkbox" value="check me" />

<input type="button" value="Say hello" onClick="showAlert('Hello Android!')" />

<script type="text/javascript">

function showAlert(t) {

alert(t);

}

</script>

 
which I'm loading like so...
 
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebChromeClient(new WebChromeClient(){
            @Override
         public boolean onJsAlert(WebView view, String url, String message, JsResult result){
             Toast.makeText(_ctx, message, Toast.LENGTH_SHORT).show();
           return true;
         }
        });
        webView.loadUrl("file:///android_asset/test.htm");
 
When I click the button the first time, the alert() displays.  If i click the button a second time nothing happens.  In fact the button stays selected (orange) and I cannot click on anything else, i.e. the page seems to hang.
 
I noticed an unresolved issue with the javascriptinterface for this android version.   Is this also just broken in android 2.3?
 

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate