我在webview中加载检查字符串
String Check = "<html><body><form action=\"https://sandbox.google.com/checkout/api/checkout/v2/checkoutForm/Merchant/**ID**\" id=\"BB_BuyButtonForm\" method=\"" +
"post\" name=\"" +"BB_BuyButtonForm\" target=\"_top\">"
+"<input name=\"item_name_1\" type=\"hidden\" value=\"Carbon Emission\"/>"
+"<input name=\"item_description_1\" type=\"hidden\" value=\"Pay for carbon emission. \"/>"
+"<input name=\"item_quantity_1\" type=\"hidden\" value=\"1\"/>"
+"<input name=\"item_price_1\" type=\"hidden\" value=\"ffff\"/>"
+"<input name=\"item_currency_1\" type=\"hidden\" value=\"USD\"/>"
+"<input name=\"_charset_\" type=\"hidden\" value=\"utf-8\"/>"
+"<input alt=\"\" src=\"https://sandbox.google.com/checkout/buttons/buy.gif?merchant_id=**ID**&&w=117&&h=48&&style=trans&&variant=text&&loc=en_US\" type=\"Button\"/>"
+"</form></body></html>";
然后我将检查字符串加载到webview
webview.loadData(Check, "text/html", "UTF_8");
显示白屏
答案 0 :(得分:2)
非常感谢Nappy和Sandy。
最后我解决了我的问题。这是因为安全网址https。这不会直接在webview中运行所以我们必须避免ssl错误
webview.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
pd.dismiss();
}
@Override
public void onReceivedSSLError(WebView view, int errorCode,
String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
view.proceed();
}
});
答案 1 :(得分:1)
创建类如下
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
然后在webView.setWebViewClient(new HelloWebViewClient());
webview.loadUrl(authUrl);
答案 2 :(得分:1)
您可能想要更改
setInitialScale(1);
到
setInitialScale(100);
因为参数需要百分之一的价值。