在我的webview上载图片按钮不起作用,但是在浏览器中它起作用了吗? [英] In my webview upload image button not working but in browser it's working?
本文介绍了在我的webview上载图片按钮不起作用,但是在浏览器中它起作用了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的webview上传图像按钮中不起作用,但是在浏览器上它工作正常,但在我的webview应用程序中却不起作用?我的应用程序在Kotlin中而不是Java中.任何人都知道如何解决此问题.我只想通过此按钮上传图像.
In my webview upload image button not working but on browser it's working good but not in my webview app? My app is in Kotlin not Java. Anybody know how to solve this issue. I just want to upload an image by this button.
在浏览器图像上:
on browser image:
mainactivity.kt
package com.little.example
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.webkit.WebBackForwardList
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import com.little.example.R
import kotlinx.android.synthetic.main.activity_main.*
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import androidx.core.app.ComponentActivity
import androidx.core.app.ComponentActivity.ExtraData
import androidx.core.content.ContextCompat.getSystemService
import android.icu.lang.UCharacter.GraphemeClusterBreak.T
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
webview.settings.javaScriptEnabled = true
webview.loadUrl("https://little.com")
webview.webViewClient = MyWebViewClient()
}
override fun onBackPressed() {
if (webview.canGoBack()){
webview.goBack()
}
else {
super.onBackPressed()
}
}
private inner class MyWebViewClient : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
if (!url.contains("little.com")) {//for example
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
return true
}
view.loadUrl(url)
return false
}}
}
推荐答案
请在webview.settings.javaScriptEnabled = true
下方的Webview
设置中添加:
please add into your Webview
settings, below the webview.settings.javaScriptEnabled = true
:
webview.settings.domStorageEnabled = true
这篇关于在我的webview上载图片按钮不起作用,但是在浏览器中它起作用了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文