Android Webview根本不显示
这是我的代码,在我的应用程序上看不到任何webview。我试图创建一个按钮,我可以看到。当我运行我的应用程序时,只有一个空格代替了webviewAndroid Webview根本不显示,android,webview,Android,Webview,这是我的代码,在我的应用程序上看不到任何webview。我试图创建一个按钮,我可以看到。当我运行我的应用程序时,只有一个空格代替了webview <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmln
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|top"
android:orientation="vertical"
tools:context="com.example.user.calisma1.MainActivity">
<Button
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/b"/>
<WebView
android:id="@+id/wv"
android:layout_width="match_parent"
android:layout_height="300dp"></WebView>
在清单中添加internet权限(如果未添加):
<uses-permission android:name="android.permission.INTERNET"/>
您的url涉及使用HTTPSSSL重定向,因此,应添加以下行
wv2.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
// Handle the error
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
wv2.loadUrl("https://webmail.etu.edu.tr/");
你已经允许上网了吗?是的,我很抱歉没有附上
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
// Handle the error
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
wv2.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
// Handle the error
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
wv2.loadUrl("https://webmail.etu.edu.tr/");