服务器之家

服务器之家 > 正文

android控件之WebView控件缩小

时间:2021-01-16 13:47     来源/作者:Android开发网
复制代码 代码如下:

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 = "http://www.zzvips.com",
                    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);
        }
    }
}

标签:

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
Intellij idea2020永久破解,亲测可用!!!
Intellij idea2020永久破解,亲测可用!!! 2020-07-29
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享 2020-04-07
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总 2020-11-13
返回顶部