Archive for January, 2011

Slow Android autocomplete in Eclipse Helios

Eclipse Helios has been slow for me for awhile, and it finally annoyed me enough to try to google a solution.

This guy found a good, relatively easy fix.

Basically, you’re just downloading the Android source, and adding it to your Android SDK directory. Hit the link for full details.

Comments off

Referencing drawables in HTML in Android’s WebView

Here’s another interesting Android quirk:

So let’s say you have a webview that you want to populate with HTML from an arbitrary source, and you want to use an image in the res/drawable directory. You could try webview.loadData(html, “text/html”, “UTF-8″), and within the HTML, use

<img src="file:///android_res/drawable/icon.png" />

or something, but that won’t work. Instead, this is what I had to do:

WebView webview = (WebView)this.findViewById(R.id.webview);
String html = "<html><head><title>TITLE!!!</title></head>";
html += "<body><h1>Image?</h1><img src="icon.png" /></body></html>";
webview.loadDataWithBaseURL("file:///android_res/drawable/", html, "text/html", "UTF-8", null);

So basically, for some reason, you absolutely have to use loadDataWithBaseURL.

UPDATE

This only seems to work with 2.2 (API level 8)and up.

Comments off

Related Links

Resource Links