我正在尝试在我的应用程序 (android Studio) 中实现一个 webview。这很容易。不幸的是,并非所有域都已加载:
String url="https://www.secretdomain.ch/"; //sorry i must remove the domain
webView=(WebView)rootView.findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(false);
webView.loadUrl(url);
这行不通,没有页面加载。
当我尝试 https://www.google.ch/或 https://stackoverflow.com/一切正常。
这可能是什么原因?我不认为这是网站本身,因为在 ios (Xamarin) 上,webview 工作没有任何问题。有解决方法吗?
最佳答案
这样试试
xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#ff00ff">
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
类(class):
{
{
wb=(WebView)findViewById(R.id.webView1);
wb.loadUrl("https://www.dkh.ch/");
wb.setWebViewClient(new WebViewClient());
}
}
关于android - webview 不适用于所有域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47051291/