我为我的网站创建了一个webview,该页面托管在我的服务器中,当检查具有手机设置的元素时,该页面工作正常,但是当同一页面加载到android中的webview时,单击按钮不执行任何操作,图片未加载
我添加了行
val mWebSettings = mWebView.getSettings()
mWebSettings.setJavaScriptEnabled(true)
mWebSettings.setDomStorageEnabled(true)
mWebSettings.setSupportZoom(false)
mWebSettings.setAllowFileAccess(true)
mWebSettings.setAllowContentAccess(true)
MainAcitvity
package com.example.student.myapplication
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import android.webkit.WebSettings
class MainActivity : AppCompatActivity() {
var mWebView: WebView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
mWebView = findViewById<WebView>(R.id.webview);
val mWebSettings = mWebView.getSettings()
mWebSettings.setJavaScriptEnabled(true)
mWebSettings.setDomStorageEnabled(true)
mWebSettings.setSupportZoom(false)
mWebSettings.setAllowFileAccess(true)
mWebSettings.setAllowContentAccess(true)
mWebView!!.webViewClient = object : WebViewClient(){
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean{
view?.loadUrl(url)
return true
}
}
mWebView!!.loadUrl("https://qiwi.io/")
}
}
该行出现错误
val mWebSettings = mWebView.getSettings()
答案 0 :(得分:0)
尝试关注...
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW)
科特林
webView.settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW