android控件之WebView控件缩小
代码如下:
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);
}
}
}
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341