简体   繁体   English

在Webview中加载本地图像和服务器数据的混合

[英]Load mix of local images and server data in Webview

I have a webview contain Listview displays Posts data like Name, Image, Price etc. These post images are fixed. 我有一个包含Listview显示器的webview帖子数据,例如名称,图像,价格等。这些帖子图像是固定的。 Total 10 type of posts hava 10 different fixed images. 共有10种帖子类型,其中有10种不同的固定图片。 Images taking much time to load so i need to load images from local drawable folder and data from server as earlier. 图像需要花费很多时间来加载,因此我需要像之前那样从本地可绘制文件夹中加载图像,并从服务器中加载数据。 I seen some ways as below, but none of them worked well. 我看到了以下几种方法,但是没有一种能很好地工作。 I want images to load in webview without uploading to server. 我想将图像加载到webview中而不上传到服务器。 Please let me know if any way to do this with less loading time. 请让我知道是否有任何方法可以减少加载时间。

1) webView.loadUrl("file:///android_asset/image.jpg");  // Loading only local image
2) webView.loadUrl("javascript:uploadImages(" + jobj + ")");  // Much Upload and load times

Please store your all images in drawable and you can setImage after that: 请将所有图像存储在drawable中,然后可以设置setImage:

holder.imgVIew.setBackground(getResources().getDrawable(R.drawable.ic_wedding_apps));

And While you have set a image to ImageView Hide the WebView.. 并且在将图像设置为ImageView之后,隐藏WebView。

I hope you got my point 我希望你明白我的意思

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM