Comments (1)
- 可以通过使用 WebView.loadData(String data, String mimeType, String encoding)) 方法来加载一整个 HTML 页面的一小段内容,第一个就是我们需要 WebView 展示的内容,第二个是我们告诉 WebView 我们展示内容的类型,一般,第三个是字节码,但是使用的时候,这里会有一些坑
- 明明已经指定了编码格式为 UTF-8,加载却还会出现乱码……
String html = new String("<h3>我是loadData() 的标题</h3><p>  我是他的内容</p>"); webView.loadData(html, "text/html", "UTF-8");
- 使用loadData()或 loadDataWithBaseURL()加载一段HTML代码片段
- data:是要加载的数据类型,但在数据里面不能出现英文字符:'#', '%', '' , '?' 这四个字符,如果有的话可以用 %23, %25, %27, %3f,这些字符来替换,在平时测试时,你的数据时,你的数据里含有这些字符,但不会出问题,当出问题时,你可以替换下。
- %,会报找不到页面错误,页面全是乱码。乱码样式见符件。
- #,会让你的goBack失效,但canGoBAck是可以使用的。于是就会产生返回按钮生效,但不能返回的情况。
- \ 和? 我在转换时,会报错,因为它会把\当作转义符来使用,如果用两级转义,也不生效,我是对它无语了。
- 我们在使用loadData时,就意味着需要把所有的非法字符全部转换掉,这样就会给运行速度带来很大的影响,因为在使用时,在页面stytle中会使用很多%号。页面的数据越多,运行的速度就会越慢。
- data中,有人会遇到中文乱码问题,解决办法:参数传"utf-8",页面的编码格式也必须是utf-8,这样编码统一就不会乱了。别的编码我也没有试过。
- data:是要加载的数据类型,但在数据里面不能出现英文字符:'#', '%', '' , '?' 这四个字符,如果有的话可以用 %23, %25, %27, %3f,这些字符来替换,在平时测试时,你的数据时,你的数据里含有这些字符,但不会出问题,当出问题时,你可以替换下。
- 解决办法
String html = new String("<h3>我是loadData() 的标题</h3><p>  我是他的内容</p>"); webView.loadData(html, "text/html;charset=UTF-8", "null");
from ycwebview.
Related Issues (20)
- 打开相册选择图片上传取不到数据这个要怎么处理
- 升级新版本后 部分手机出现X5WebView初始化时空指针异常 HOT 6
- 在视频未播放之前,点击全屏按钮,已经切为横屏,但是没有播放视频
- Google商店 海外应用能支持X5吗 我看官方文档都是说不行 HOT 1
- 希望支持ppt和pdf的代码翻页
- 调起支付宝支付提示操作超时
- X5WebView是不是不支持访问res中的视频资源?
- Binary XML file line #8: Error inflating class com.ycbjie.webviewlib.view.X5WebView HOT 2
- 不维护了吗? HOT 3
- master项目下载下来,打包aar,在实际项目中使用报资源找不到java.lang.NoSuchFieldError: No static field abc_dialog_material_background_dark of type I in class
- 红米手机无法打开文件,报错是说不支持x5内核 HOT 1
- Android 6.0手机无法使用JsBridge
- com.ycbjie.webviewlib.view.X5WebViewActivity闪退
- H5页面调用全屏时,webview自动横屏显示了
- android 12 这个属性必填 android:exported HOT 1
- 播放视频退出全屏后页面黑屏了,但是有声音 HOT 1
- 播放视频退出全屏后,整个页面黑屏 HOT 2
- demo跑不起来了 HOT 4
- 请问还维护吗?
- 这个库不维护了吗 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ycwebview.