To load the data in WebView from html-file!!!!

Put your problem here if it does not fit any of the other categories.

To load the data in WebView from html-file!!!!

Postby beaster » Tue Oct 07, 2008 10:48 am

I have big html-file.How to load the data in WebView from html-file?????????????Help please.
The html-file contains javascript and html-code.
beaster
Junior Developer
Junior Developer
 
Posts: 16
Joined: Tue Oct 07, 2008 10:43 am

Top

Postby plusminus » Tue Oct 07, 2008 2:13 pm

the assets folder or res/raw should work.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby beaster » Tue Oct 07, 2008 3:02 pm

How to load the data in WebView from Sting?????????
The String contains unicode-char ({,Ͽ,......)
WebView.loadData(String,"text/html","utf-8") Does not work!!!!!!! :?:
beaster
Junior Developer
Junior Developer
 
Posts: 16
Joined: Tue Oct 07, 2008 10:43 am

Postby plusminus » Tue Oct 07, 2008 4:17 pm

Because your Unicode chars arw wrong :)

You use:
{

instead of: {; which turns out to be the following char: {

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby beaster » Tue Oct 07, 2008 7:58 pm

Here - "
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class Hello extends Activity {
  2.       public void onCreate(Bundle icicle) {
  3.         super.onCreate(icicle);
  4.         setContentView(R.layout.main);
  5.          final String mimeType = "text/html";
  6.         final String encoding = "utf-8";
  7.         WebView wv;
  8.         wv = (WebView) findViewById(R.id.wv1);
  9.         wv.loadData("" ", mimeType, encoding);
  10.      
  11.    }
  12. }
  13.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

Does not display symbols!!!!!
But
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  wv.loadData("" ", mimeType, encoding);
  2.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

Works!!!!!!
" - Symbolical representation "
Where an error??????
beaster
Junior Developer
Junior Developer
 
Posts: 16
Joined: Tue Oct 07, 2008 10:43 am

Postby plusminus » Tue Oct 07, 2008 8:17 pm

I'll check that when I'm back home...
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby beaster » Tue Oct 07, 2008 8:51 pm

Well! I will wait!
Thus the following code does not work also
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onCreate(Bundle icicle) {
  2.            try {
  3.        super.onCreate(icicle);
  4.        setContentView(R.layout.main);
  5.        WebView wv;
  6.        InputStream is = getAssets().open("demo.html"); //open html-file
  7.         int size = is.available();
  8.        
  9.         byte[] buffer = new byte[size];
  10.        is.read(buffer);
  11.        is.close();
  12.        String text=new String(buffer);
  13.        wv = (WebView) findViewById(R.id.wv1);
  14.        wv.loadData(text, "text/html", "utf-8");
  15.                 } catch (IOException e) {
  16.                         throw new RuntimeException(e);
  17.                 }  
  18.    }
  19. }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4

not work
??????????????????
beaster
Junior Developer
Junior Developer
 
Posts: 16
Joined: Tue Oct 07, 2008 10:43 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 13 guests