效果图:
HomeActivity.class:
package com.example.liangminghuitwo; import com.example.vo.Content; import com.google.gson.Gson; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.webkit.WebView; public class HomeActivity extends Activity{ private WebView web_view; String info_url="http://www.93.gov.cn/93app/info.do?id="; Handler han=new Handler(){ public void handleMessage(android.os.Message msg) { String rs=(String) msg.obj; Gson g=new Gson(); Content content=g.fromJson(rs,Content.class); String contenttext=content.getContenttext(); web_view.loadData(contenttext, "text/html;charset=utf-8","utf-8"); }; }; protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.home); web_view=(WebView) findViewById(R.id.web_view); Intent it=getIntent(); final String id=it.getStringExtra("id"); new Thread(){ public void run() { String getdata=Myutils.getData(info_url+id); han.sendMessage(han.obtainMessage(1,getdata)); }; }.start(); } }
页面xml里面就是一个简单的webview