views:

187

answers:

2

Following is my html content which i want to show in the webview using android sdk. It will displays only

//Please

but when i put this html content into the browser then it shows differently.

<br /><br />Read the handouts please for tomorrow.<br /><br /><!--homework help homework


help help with homework homework assignments elementary school high school middle school



// --><font color="#60c000" size="4"><strong>Please!</strong></font>

Please Suggest me how to resolve this problem

I have another problem that in html content there is a tag

<img src="http://www.homeworknow.com/hwnow/upload/images/tn_star300.gif" border="0" />

in this images does not shows

Please help me to resolve the problem

A: 

A good example showing the use of WebView is here (with source). On this site you will find a lot of examples on using android.

naikus
this example gives same results as i do
Amit Thaper
A: 
  1. Use web.loadDataWithBaseURL instead of web.loadData (And don't forget to escape strings where it's needed)
  2. You need to add internet permission to download images and view them in your manifest file.

This example works for me:

public class SimpleMusicStream extends Activity {
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);

        WebView wv = (WebView) findViewById(R.id.WebView01);        

        final String mimeType = "text/html";
        final String encoding = "UTF-8";
        String html = "<br /><br />Read the handouts please for tomorrow.<br /><br /><!--homework help homework" +
                "help help with homework homework assignments elementary school high school middle school" +
                "// --><font color='#60c000' size='4'><strong>Please!</strong></font>" +
                "<img src='http://www.homeworknow.com/hwnow/upload/images/tn_star300.gif'  />";


        wv.loadDataWithBaseURL("", html, mimeType, encoding, "");
    }

}

And don't forget to add:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

in your AndroidManifest.xml file

droidgren