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

posted @   151  阅读(159)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core内存结构体系(Windows环境)底层原理浅谈
· C# 深度学习:对抗生成网络(GAN)训练头像生成模型
· .NET 适配 HarmonyOS 进展
· .NET 进程 stackoverflow异常后,还可以接收 TCP 连接请求吗?
· SQL Server统计信息更新会被阻塞或引起会话阻塞吗?
阅读排行:
· 传国玉玺易主,ai.com竟然跳转到国产AI
· 本地部署 DeepSeek:小白也能轻松搞定!
· 自己如何在本地电脑从零搭建DeepSeek!手把手教学,快来看看! (建议收藏)
· 我们是如何解决abp身上的几个痛点
· 普通人也能轻松掌握的20个DeepSeek高频提示词(2025版)
点击右上角即可分享
微信分享提示