Android 像这样使用WebView可以吗?

Android 像这样使用WebView可以吗?,android,android-webview,Android,Android Webview,我在src中为webview中的标记使用drawables,这样行吗 mWebView.loadDataWithBaseURL("","<table width=\"100%\"><tr><td style=\"text- align:center; background-color:grey;\"><img src=\""+R.id.button+"\"/></td></tr>

我在src中为webview中的标记使用drawables,这样行吗

     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", "");
mWebView.loadDataWithBaseURL(“,”
“+问题,”text/html“,”utf-8“,”);
我在src中为webview中的标记使用drawables,这样行吗

     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", "");
绝对不是。HTML需要图像的URL。更不用说您指定的是小部件ID,而不是可绘制的资源


先生,这真的很有帮助,但它在模拟器上工作正常,但在设备上工作不正常。你知道如何解决这个问题吗

也许你的设备比较旧——克莱森先生联系到的一个问题的答案是
file:///android_res/
URL仅适用于Android 2.2及更高版本

然而,
android.resource
方案的存在时间更长:

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

e、 g:

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


我没有在
WebView
中尝试过这一点,但值得一试。

sir这确实有帮助,但它在emulator上正常工作,但在设备上没有。你知道如何解决吗?Thanx,但sir这也不起作用。@Navdroid:那么在HTML中使用图像资源可能根本不可能,至少在旧版本的Android上是如此。您可以将图像移动到
assets/
并使用
file:///android_asset/
Uri
值来引用它们。