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);
}
}
}