tags:

views:

314

answers:

1

Hi,

I want to display one static HTML page in my android emulator. I don't know how to do this. Please anybody help me.

+3  A: 

I'm assuming you want to display your own page in a webview?

Create this as your activity:

public class Test extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webview = new WebView(this);
        setContentView(webview);
        try {
            InputStream fin = getAssets().open("index.html");
      byte[] buffer = new byte[fin.available()];
      fin.read(buffer);
      fin.close();
      webview.loadData(new String(buffer), "text/html", "UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

This will read the file 'index.html' from your project assets/ folder.

Tim H