Wednesday 1 May 2013

Android: android with HTML

WebViewActivity.java


public class WebViewActivity extends Activity {

 @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);

       WebView webView = (WebView) findViewById(R.id.webView1);
       webView.getSettings().setJavaScriptEnabled(true);
       webView.setWebChromeClient(new WebChromeClient());
       webView.loadUrl("file:///android_asset/file.html");
   }

}


activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".WebViewActivity" >

    <WebView
        android:id="@+id/webView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</LinearLayout>


file.html

<!DOCTYPE html>
<html>
<head>
</head>
<body style="background-color:#FFFFFF;">
username<br/>
<input type="text"><br/>
password<br/>
<input type="password">
<input type="button" value="Click">
</body>
</html>

No comments:

Post a Comment