2

In my Application, I display data in webview but it can't display the images in the webview.

I used loadDatawithBaseURL() method.

This is my code..

webview.loadDataWithBaseURL("file:///059600656X/", data, "text/html", "UTF-8", "about:blank");

// here data is a string object which contain html parsing data.

I think it cant find the images in given directory.

Can Anybody help me?

Dean J
  • 39,360
  • 16
  • 67
  • 93
Addy
  • 259
  • 1
  • 5
  • 11
  • no. there is no any comment in the logcat. – Addy Apr 14 '10 at 12:38
  • Please search for similar questions before posting a new one... Just yesterday someone asked about this and found a way to solve his problem: http://stackoverflow.com/questions/2630829/android-display-res-viewable-in-webview. If I could, I'd vote to close this question as a duplicate. – Steve Haley Apr 14 '10 at 12:45

3 Answers3

0

You cannot use simple file:/// URLs with loadDataWithBaseURL(), and "about:blank" probably is not a valid base URL.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

To make the loadDataWithBaseURL work you need to make sure of two things:

All image src include "file:///android_asset/imagename"

and the images are in the asset folder!!

So contrary to answer1, it is as simple as that!

Munir Syed

0

When you use LoadDataWithBaseURL you must specify the image resource as ur baseurl and data must be ur array or image renderer.

example

wv.loadDataWithBaseURL("file:///android_asset/", srray[position], "text/html", "UTF-8", null);

this should help me out

Esailija
  • 138,174
  • 23
  • 272
  • 326
cavallo
  • 4,414
  • 9
  • 39
  • 61