【问题标题】:progress bar in WebView using kotlin使用 kotlin 的 WebView 中的进度条
【发布时间】:2018-10-24 19:53:40
【问题描述】:

我正在使用此代码显示进度条,同时将 url 加载到 WebView 中,但应用程序在 webview 页面启动几秒钟后崩溃,它给了我错误:

java.lang.IllegalArgumentException:指定为非空的参数是 null:方法 kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, 参数图标

  val progressBar = findViewById<ProgressBar>(R.id.prg)
    val url: String = intent.getStringExtra("targetURL") ?: ""


    webView.webViewClient = object : WebViewClient() {

        override fun onPageStarted(view: WebView, url: String, favicon: Bitmap) {
            super.onPageStarted(view, url, favicon)
            view.visibility =View.INVISIBLE
            progressBar.visibility = View.VISIBLE
        }

        override fun onPageFinished(view: WebView, url: String) {
            super.onPageFinished(view, url)
            view.visibility =View.VISIBLE
            progressBar.visibility = View.INVISIBLE
        }

    }
    webView.settings.javaScriptEnabled = true

    val settings = webView.settings
    settings.domStorageEnabled = true

    webView.loadUrl(url)

【问题讨论】:

    标签: android android-studio kotlin progress-bar


    【解决方案1】:

    使favicon 可以为空。

    改变

    favicon: Bitmap
    

    favicon: Bitmap?
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-02
      • 1970-01-01
      • 2017-06-24
      相关资源
      最近更新 更多