CSS in WebView

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

CSS in WebView

Postby mitchellj » Sun Dec 21, 2008 1:31 pm

[syntax="xml"]Hiya,

I'm having a slightly strange problem, I'm using a WebView widget in a page, when I put HTML in the widget using loadData it works fine, however if I include a <style> tag in the HTML the widget goes blank and doesn't show any details.

The initial code is
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 WebView oBrowser = (WebView)this.findViewById(R.id.wineResultHTMLViewer);
  2.  
  3.  
  4.  
  5.                 String szHTML = "<html><head><title>Wine Detail</title><style type=\"text/css\">.moo {color: #000000;}</style></head><body><div class=\"wine\"><div class=\"header\"><h1>1972 Achaia Clauss Nemea</h1></div><br clear=\"all\"/><div class=\"winelabel\">&nbsp;</div></body></html>";
  6.  
  7.                 oBrowser.loadData(szHTML, "text/html", "UTF-8");
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


This should do nothing more than display a peice of text in H1 on the page. However it just displays a blank screen, removing the section which says
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. <style type=\"text/css\">.moo {color: #000000;}</style>
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
fixes the problem.

For reference the XML is :-
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout
  5.  
  6.         xmlns:android="http://schemas.android.com/apk/res/android"
  7.  
  8.         android:orientation="vertical"
  9.  
  10.         android:layout_width="fill_parent"
  11.  
  12.         android:layout_height="fill_parent" >
  13.  
  14.         <AutoCompleteTextView android:id="@+id/edit"
  15.  
  16.                 android:layout_width="fill_parent"
  17.  
  18.                 android:layout_height="wrap_content"
  19.  
  20.                 android:completionThreshold="3" android:height="44px"/>
  21.  
  22.         <WebView android:id="@+id/wineResultHTMLViewer"
  23.  
  24.                 android:layout_width="fill_parent"
  25.  
  26.                 android:layout_height="fill_parent"
  27.  
  28.         />
  29.  
  30.         </LinearLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


Any help is apprechiated!

Thanks
mitch
mitchellj
Freshman
Freshman
 
Posts: 3
Joined: Sun Dec 21, 2008 1:19 pm

Top

Postby mitchellj » Tue Dec 23, 2008 11:26 pm

I don't suppose anyone has been able to replicate this problem or seen it before have they?

I've been banging my head over this one for ages now :|

Thanks!
mitch
mitchellj
Freshman
Freshman
 
Posts: 3
Joined: Sun Dec 21, 2008 1:19 pm

Postby mitchellj » Sat Dec 27, 2008 1:45 am

Looks like its a bug in android SDK

http://code.google.com/p/android/issues/detail?id=1659

Thanks
mitch
mitchellj
Freshman
Freshman
 
Posts: 3
Joined: Sun Dec 21, 2008 1:19 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests