如果URL以特定字符串結尾,我使用以下代碼來隱藏webview。URL加載後無法隱藏webview
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
if (url.endsWith("index.asp")) {
Toast.makeText(getActivity().getApplicationContext(),"Login successfull",Toast.LENGTH_LONG).show();
webview.setVisibility(view.GONE);
}
}
});
但仍web視圖如果URL以的index.asp(例如 「http://abc.def/index.asp」)
爲什麼你隱藏webview'onPageFinished'?檢查url是否以該字符串結尾。如果沒有打開webview,否則不顯示它。 – hrskrs
嘗試通過LinearLayout或FragmentView打包webview。你讀過這個http://stackoverflow.com/questions/7942219/show-hide-webview-issue? – Vyacheslav
調試並測試您檢查的條件是否令人滿意。 –