12345

A great WordPress.com site

How to Run HTML in android Emulator

Leave a comment

 

3 Easy steps to Run Html in android

1) Copy html file in assets in project dir

2) Arrange WebView in Layout

3) Link with Java Code.

 

Xml File

<?xml version=”1.0″ encoding=”utf-8″?>
<WebView xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:id=”@+id/webtest”></WebView>

Java File

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class Main extends Activity {
public void onCreate(Bundle SavedInstanceState)
{
super.onCreate(SavedInstanceState);
setContentView(R.layout.main);
WebView mWebView = null;
mWebView = (WebView) findViewById(R.id.webtest);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(“file:///android_asset/index.html”);

}

}

 

Now see Html o/p in emulator.

Thank you.

About these ads

Author: 123

tgoih

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.