• 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

  • 相关阅读:
    svn上传文件钩子
    linux服务器版svn安装
    csp-s模拟55
    csp-s模拟54
    csp-s模拟53
    csp-s模拟52
    csp-s模拟51
    csp-s模拟50
    csp-s模拟49
    csp-s模拟48
  • 原文地址:https://www.cnblogs.com/123p/p/5404639.html
Copyright © 2020-2023  润新知