zoukankan      html  css  js  c++  java
  • webview加载网页显示

    效果图:

    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

  • 相关阅读:
    Grovvy初识
    在eclipse中安装插件
    解决 APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tas
    Axis2 webservice入门--Webservice的发布与调用
    一步一步教你自定义博客园(cnblog)界面
    Enum枚举
    并行与并发
    多线程join(加入)
    守护线程
    停止线程
  • 原文地址:https://www.cnblogs.com/123p/p/5404639.html
Copyright © 2011-2022 走看看