Sunday, June 10, 2012

[Android] webView with a table format of HTML




WebView with a table format of HTML.
package ByungYong.library.webView;

import android.app.*;
import android.os.*;
import android.view.*;
import android.webkit.*;
import android.widget.*;

public class WebViewActivity extends Activity {
 WebView mWeb;
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  mWeb = (WebView)findViewById(R.id.web);
        mWeb.loadUrl("file:///android_asset/test.html");
        mWeb.getSettings().setJavaScriptEnabled(true);
        mWeb.getSettings().setSaveFormData(true);
        mWeb.getSettings().setBuiltInZoomControls(true);
        mWeb.setWebViewClient(new MyWebClient());
 }

 
 class MyWebClient extends WebViewClient {
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
   view.loadUrl(url);
   return true;
  }
 }
}
layout can be like this.

Add HTML code into assets.

Don't forget add the code below on AndroidManifest.xml


No comments: