因为Android软件开发分工目前还没有细化,程序员往往需要负责软件界面的开发,虽然软件的界面图片已经由美工设计好了,但是如果使用layout技术把软件做成漂亮的界面确实很困难,而是也比较耗时。Android通过WebView实现了JS代码与Java代码互相通信的功能,使的Android软件的界面开发也可以采用HTML网页技术,这样,广大网页美工可以参与进Android软件的界面开发工作,从而让程序员从中解脱出来。
工程目录
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>Wty htmlUI</title>
<script type="text/javascript">
function show(jsondata){
// [{name:"xxx",amount:600,phone:"13988888"},{name:"bb",amount:200,phone:"1398788"}]
var jsonobjs = eval(jsondata);
var