2011-08-08 74 views
0

我加載網頁視圖Web視圖不加載HTML內容

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**&amp&w=117&amp&h=48&amp&style=trans&amp&variant=text&amp&loc=en_US\" type=\"Button\"/>" 
      +"</form></body></html>"; 

內檢查字符串然後我加載檢查字符串的WebView

 webview.loadData(Check, "text/html", "UTF_8"); 

它顯示白色畫面

回答

1

非常感謝Nappy和Sandy。

最後我解決我的problem.It是因爲安全網址的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(); 
     } 

    }); 
+0

+1分享 – Praveenkumar

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.loadUrl(authUrl);

+0

不工作,依然呈現白屏 – Sameer

+0

你已經添加互聯網權限聲明manifest.xml? – Sandy

+0

是的,我已經添加了,因爲我正在創建鏈接集成,所以我已經非法添加它 – Sameer

1

你可能會想改變

setInitialScale(1)添加此語句webView.setWebViewClient(new HelloWebViewClient());;

setInitialScale(100);

因爲參數需要百分之值。