Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> android控件之WebView控件縮小

android控件之WebView控件縮小

編輯:關於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.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);
        }
    }
}

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved