0

I am using drawables in src for tag in webview would this work?

     mWebView.loadDataWithBaseURL("","<table width=\"100%\"><tr><td style=\"text-
     align:center; background-color:grey;\"><img src=\""+R.id.button+"\"/></td></tr>                
     </table>"+Question, "text/html", "utf-8", "");
Navdroid
  • 4,453
  • 7
  • 29
  • 47
  • sir that really helped but it is working correctly on emulator but not on the device .Do you know how to solve it? – Navdroid Jan 18 '12 at 12:42

1 Answers1

0

I am using drawables in src for tag in webview would this work?

Absolutely not. HTML expects URLs for images. Not to mention that you are specifying a widget ID, not a drawable resource.

sir that really helped but it is working correctly on emulator but not on the device .Do you know how to solve it?

Perhaps your device is older -- one answer on the question that Mr. Clayson linked to suggests that file:///android_res/ URLs only work on Android 2.2 and higher.

However, the android.resource scheme has been around longer:

android.resource://[package]/[res type]/[res name]

e.g.:

android.resource://this.is.my.package/drawable/button

I have not tried this in WebView, but it is worth a shot.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanx,But Sir this also not working. – Navdroid Jan 18 '12 at 13:42
  • @Navdroid: Then using image resources in HTML may simply not be possible, at least on older versions of Android. You can move your images into `assets/` and use `file:///android_asset/` `Uri` values to reference them. – CommonsWare Jan 18 '12 at 14:01