欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

android控件之WebView控件缩小

程序员文章站 2023-12-09 23:13:51
复制代码 代码如下:package com.weizhu.lan.view; import com.weizhu.lan.util.myprogressdialog;...

复制代码 代码如下:

package com.weizhu.lan.view;

import com.weizhu.lan.util.myprogressdialog;

import android.app.activity;
import android.app.alertdialog;
import android.content.context;
import android.content.intent;
import android.net.connectivitymanager;
import android.os.asynctask;
import android.os.bundle;
import android.os.handler;
import android.view.keyevent;
import android.view.window;
import android.webkit.webchromeclient;
import android.webkit.webview;
import android.widget.progressbar;

public class helpcenter extends activity {

    //50766649
    private string urlhelp = "//www.jb51.net",
                    userid = "userid=";
    private string yqhid;
    private webview web;
    private handler hand;
    private progressbar pb;
    private myasynctask myasy;
    @override
    protected void oncreate(bundle savedinstancestate) {

        super.oncreate(savedinstancestate);
        requestwindowfeature(window.feature_no_title);
        setcontentview(r.layout.help_webview);

        yqhid = getintent().getstringextra("yqhid");

        web = (webview) findviewbyid(r.id.help_webview1);
        web.getsettings().setbuiltinzoomcontrols(true); //可放大、缩小
        myasy = new myasynctask();
        final string str = urlhelp;
            myasy.execute(str);

    }
    class myasynctask extends asynctask<string, string, void>{

        @override
        protected void doinbackground(string... params) {
            web.loadurl(params[0]);
            web.setwebchromeclient(new webchromeclient(){
                @override
                public void onprogresschanged(webview view, int newprogress) {
                    super.onprogresschanged(view, newprogress);
                    pb.setprogress(newprogress); //它自己会处置进度条
                }
            });
            return null;
        }
        @override
        protected void onpostexecute(void result) {

        }
        @override
        protected void onpreexecute() {
            pb = (progressbar) findviewbyid(r.id.help_progressbar2);
            pb.setprogress(0);
        }
    }
}