WebView of android Control

Source: Internet
Author: User

I found this control is quite useful and can control the progress bar by myself, and the control is very powerful. I will explain it later.

First, a simple

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.baidu.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); // you can zoom in or out.
MyAsy = new MyAsyncTask ();
Final String str = urlHelp;
MyAsy.exe cute (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); // it handles the progress bar by itself
Return null;
@ Override
Protected void onPostExecute (Void result ){

@ Override
Protected void onPreExecute (){
Pb = (ProgressBar) findViewById (R. id. help_progressBar2 );
Pb. setProgress (0 );


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.