The following code shows how to load static html code in WebView.
Layout xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <WebView android:id="@+id/webkit" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout>
Java code
import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; /* w ww .j a v a 2s .c o m*/ public class MainActivity extends Activity { WebView browser; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); browser=(WebView)findViewById(R.id.webkit); browser.loadData("<html><body>Hello, world!</body></html>", "text/html", "UTF-8"); } }