有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法使用webview查看网页

enter image description here这是webview的xml文件

<?xml version="1.0" encoding="utf-8"?>
<安卓x.constraintlayout.widget.ConstraintLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    xmlns:app="http://schemas.安卓.com/apk/res-auto"
    xmlns:tools="http://schemas.安卓.com/tools"
    安卓:layout_width="match_parent"
    安卓:layout_height="match_parent"
    tools:context="com.example.testing.WebViewExample">

    <WebView
        安卓:layout_width="match_parent"
        安卓:layout_height="match_parent"
        安卓:id="@+id/webView"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</安卓x.constraintlayout.widget.ConstraintLayout>  

这段代码是针对Webview的。爪哇

      public class MainActivity extends AppCompatActivity {
      @Override  
      protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);  
        WebView mywebview = (WebView) findViewById(R.id.webView);  
        
        mywebview.loadUrl("https://www.google.com/");  
  
      
    }  
}  

但问题是我无法查看谷歌,它显示了一个错误,因为网页不可用

无法加载位于https://www.google.com/的网页,因为:

网络::错误\u缓存\u未命中


共 (1) 个答案