Saturday, September 8, 2012

HTML Viewer In Android

This example shows how you can show HTML files into your application.
1.) Create a new project by File-> New -> Android Project name it HTMLViewerExample.
2.) Put a .htm file into your assets folder, name it “example.htm” and write following code into it:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
    <title>HTML viewer</title>
    <style type="text/css">

            padding: 0px;
            font-size: 11pt;
            color: white;
            font-family: Arial;
            background-color: #0000FF;
            color: #FFFFFF;
            font-weight: bold;
        <div class="Help" id="Help" style="Z-INDEX: 1000; LEFT: 5%; OVERFLOW: visible; WIDTH: 90%; POSITION: absolute; TOP: 20px; HEIGHT: 500px">
            <h3>HTMLViewerExample: </h3>
                You can place your information in this HTML document.
3.) Run for output.
1.) Create a project named HTMLViewerExample and set the information as stated in the image.
Build Target: Android 2.2
Application Name: HTMLViewerExample
Package Name:
Activity Name: HTMLViewerExampleActivity
Min SDK Version: 8
2.) Open file and write following code there:
package com.example.HTMLViewerExample;
import android.os.Bundle;
import android.webkit.WebView;
public class HTMLViewerExampleActivity extends Activity {
    /** Called when the activity is first created. */
    protected void onCreate(Bundle savedInstanceState) {
                WebView wb = new WebView(this);
4.) Compile and build the project.

No comments:

Post a Comment