Android WebView向我显示空白页

时间:2018-08-02 12:18:46

标签: android android-webview

我正在尝试连接到一个网站,并使用WebView在Android手机上显示它,但它始终向我显示空白页面。 我正在尝试连接到https://givatram.ort.org.il/

我的代码:

public class MainActivity extends AppCompatActivity {




@SuppressLint({"ClickableViewAccessibility", "SetJavaScriptEnabled"})
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final WebView webview = (WebView) findViewById(R.id.webview);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setLoadWithOverviewMode(true);
    webview.getSettings().setUseWideViewPort(true);
    webview.setWebViewClient(new WebViewClient());
    webview.setWebChromeClient(new WebChromeClient());
    webview.loadUrl("https://givatram.ort.org.il/");
    }
}

XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".MainActivity">


<Button
    android:id="@+id/Main_ChangesBTN"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:layout_marginBottom="8dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/button"
    android:text="@string/Main.Changes"
    android:textAllCaps="false"
    android:textColor="#FFFFFF"
    android:textSize="25dp"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/Main_MessageBTN"
    app:layout_constraintVertical_bias="0.724" />

<Button
    android:id="@+id/Main_MessageBTN"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:layout_marginBottom="8dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/button"
    android:text="@string/Main.Messages"
    android:textAllCaps="false"
    android:textColor="#FFFFFF"
    android:textSize="25dp"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.811" />

<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="324dp"
    android:layout_marginBottom="8dp"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0" />

</android.support.constraint.ConstraintLayout>

此代码可完美地用于其他网站,但是对于这个特殊的网站,它显示空白页,此网站正常工作

0 个答案:

没有答案
相关问题