Webview of local webpage shows cluttered/repeated text

by jb » Tue, 10 Aug 2010 07:03:40 GMT


Sponsored Links
 Hi,

I display a local webpage (located in my 'assets' directory) within a
Webview. The webpage is almost exclusively text.
When displayed, the middle third of the body of text appears to be
repeated multiple times, and makes the text appear very cluttered.

I ran the webpage through the W3C html validator and it passed without
any errors.

Displaying it on regular browsers work perfectly.

Here's my code:

setContentView(R.layout.signpost);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.setBackgroundColor(0); // make the background transparent
mWebView.setBackgroundResource(R.drawable.background);
InputStreamReader is = null;
try {
        is = new
InputStreamReader(getApplicationContext().getAssets().open("signPostContent.html"));
        BufferedReader buff = new BufferedReader(is, 8192);
        StringBuffer out = new StringBuffer();
        String strLine = null;
        while ((strLine = buff.readLine()) != null) {
                out.append(strLine);
        }
        is.close();
        String mimeType = "text/html";
        String encoding = "utf-8";
        String fin = new String(out.toString());
        mWebView.loadDataWithBaseURL("file:///sdcard/data/data/
com.this.that/", fin, mimeType, encoding, "");
} catch (IOException e) {
        e.printStackTrace();
}

Any ideas?

jb

--



Webview of local webpage shows cluttered/repeated text

by Mark Murphy » Tue, 10 Aug 2010 07:20:21 GMT


 


Try using:

mWebView.loadUrl("file:///android_asset/signPostContent.html");

instead.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
Available!

--


Sponsored Links


Other Threads

1. SMS and MMS message expansion

I just got the hTC HERO from sprint, and i been going through the
settings and all I found for message size was a folder in the message
program, labled maximum message size which where 200k, 500k, and 1M.
Is there an app or upgrade to expand this to send full songs or video
clips...

--

2. ADB: error: insufficient permissions for device

I have a Motorla Cliq which I'm trying to connect to via adb. When I
run 'adb devices', this is what happens:

List of devices attached
????????????    no permissions

If I try 'adb usb', this is what happens:

error: insufficient permissions for device

This is my /etc/udev/rules.d/51-android.rules:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="22b8", ATTRS{idProduct} =="41db",
MODE="0666", OWNER="vineel"

My adb version is 1.0.25. My Cliq runs Android 1.5. I run Ubuntu 9.10.
What am I doing wrong here?

--

3. trying to install android sdk

4. What is the appropriate e-mail list?

5. getting error in gallery sample

6. jpg images noisy on sdcard but fine in gallery, only on Android 1.6 (1.5 is fine)

7. Checkout Check: An Android interface to Google Checkout