android控件之WebView控件缩小

时间:2021-05-20

复制代码 代码如下:
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 = "https://",
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);
}
}
}

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章