开发者

WebView displays a question mark in a blue box

I have a WebView that displays a Google Checkout payment button in an html form.

When I run it on the emulator it works, there is the payment button and I can press it and go to the google checkout webpage.

However, when I run it on an actual device running Android 2.2 it just shows the little blue box with a question mark.

what does this mean?

            String header = 
                "<html>" +
                    "<head>" +
                    "<script language=\"javascript\">"+
                        "function pass() {"+
                            "return checkboxState.checkboxPass();"+
                        "}"+
                    "</script>" +
                    "</head>" +
                    "<body>";

            String formData = 
            "<center>"+
            "<form onSubmit=\"return pass(开发者_JAVA技巧);\" action=\"https://"+host+"api/checkout/v2/checkoutForm/Merchant/"+merchantId+"\" id=\"BB_BuyButtonForm\" method=\"post\" name=\"BB_BuyButtonForm\" target=\"_blank\">"+
                "<input name=\"item_name_1\" type=\"hidden\" value=\""+item_name_1+"\"/>"+
                "<input name=\"item_description_1\" type=\"hidden\" value=\""+item_name_1+"\"/>"+
                "<input name=\"item_quantity_1\" type=\"hidden\" value=\"1\"/>"+
                "<input name=\"item_price_1\" type=\"hidden\" value=\""+item_price_1+"\"/>"+
                "<input name=\"item_currency_1\" type=\"hidden\" value=\""+item_currency_1+"\"/>"+
                "<input name=\"_charset_\" type=\"hidden\" value=\"utf-8\"/>"+
                "<input type=\"hidden\" name=\"shopping-cart.items.item-1.merchant-private-item-data\" value=\""+private_item_data+"\">"+
                "<input alt=\"Pay With Google Checkout\" src=\"https://"+host+"buttons/buy.gif?merchant_id="+merchantId+"&amp;w=121&amp;h=44&amp;style=trans&amp;variant=text&amp;loc=en_US\" type=\"image\"/>"+
            "</form>"+
            "</center>";

            String footer = "</body></html>";

            if(Logging.DEBUG) Log.d(TAG, header+formData+footer);

            browser = new WebView(ActivityActivate.this);
            browser.setBackgroundColor(0);
            browser.getSettings().setJavaScriptEnabled(true);
            browser.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
            browser.getSettings().setSupportZoom(false);

            browser.addJavascriptInterface(new JavascriptInterface(), "checkboxState");
            browser.loadData(header+formData+footer, "text/html", "UTF-8");
            llPaymentButtons.addView(browser);


Well I changed it to use loadDataWithBaseURL and it worked...still unsure why. Can someone elaborate?

//browser.loadData(header+formData+footer, "text/html", "UTF-8");
browser.loadDataWithBaseURL("https://checkout.google.com", header+formData+footer, "text/html", "UTF-8", null);


try this, apparently if webview does not have focus it happens

        webView.requestFocus(View.FOCUS_DOWN);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜