2014-09-23 76 views
1

我有webview:Android 4.0.4中的UploadHandler類。添加進度條到我的webview

我想添加一個進度條到網頁視圖。

我嘗試的所有代碼都不工作。 誰可以幫忙。 ??!

這個我MainAvtivity.java:

package com.com.myapplication; 

import android.app.Activity; 
import android.app.AlertDialog; 
import android.content.ActivityNotFoundException; 
import android.content.DialogInterface; 
import android.content.Intent; 
import android.net.Uri; 
import android.os.Bundle; 
import android.os.Environment; 
import android.provider.MediaStore; 
import android.view.View; 
import android.webkit.JsResult; 
import android.webkit.ValueCallback; 
import android.webkit.WebChromeClient; 
import android.webkit.WebSettings; 
import android.webkit.WebSettings.PluginState; 
import android.webkit.WebView; 
import android.webkit.WebViewClient; 
import android.widget.Toast; 

import java.io.File; 
import java.lang.reflect.Method; 
import java.net.URL; 

public class MainActivity extends Activity { 


    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     WebView webView = (WebView) findViewById(R.id.webview); 

     initWebView(webView); 
     webView.loadUrl("http://google"); // TODO input your url 

    } 

    private final static Object methodInvoke(Object obj, String method, Class<?>[] parameterTypes, Object[] args) { 
     try { 
      Method m = obj.getClass().getMethod(method, new Class[] { boolean.class }); 
      m.invoke(obj, args); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 

     return null; 
    } 

    private void initWebView(WebView webView) { 

     WebSettings settings = webView.getSettings(); 
     WebView myWebView = (WebView) findViewById(R.id.webview); 
     myWebView.setWebViewClient(new WebViewClient()); 
     settings.setJavaScriptEnabled(true); 
     settings.setAllowFileAccess(true); 
     settings.setDomStorageEnabled(true); 
     settings.setCacheMode(WebSettings.LOAD_NO_CACHE); 
     settings.setLoadWithOverviewMode(true); 
     settings.setUseWideViewPort(true); 
     settings.setSupportZoom(true); 
     // settings.setPluginsEnabled(true); 
     methodInvoke(settings, "setPluginsEnabled", new Class[] { boolean.class }, new Object[] { true }); 
     // settings.setPluginState(PluginState.ON); 
     methodInvoke(settings, "setPluginState", new Class[] { PluginState.class }, new Object[] { PluginState.ON }); 
     // settings.setPluginsEnabled(true); 
     methodInvoke(settings, "setPluginsEnabled", new Class[] { boolean.class }, new Object[] { true }); 
     // settings.setAllowUniversalAccessFromFileURLs(true); 
     methodInvoke(settings, "setAllowUniversalAccessFromFileURLs", new Class[] { boolean.class }, new Object[] { true }); 
     // settings.setAllowFileAccessFromFileURLs(true); 
     methodInvoke(settings, "setAllowFileAccessFromFileURLs", new Class[] { boolean.class }, new Object[] { true }); 

     webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); 
     webView.clearHistory(); 
     webView.clearFormData(); 
     webView.clearCache(true); 

     webView.setWebChromeClient(new MyWebChromeClient()); 
     // webView.setDownloadListener(downloadListener); 

    } 

    UploadHandler mUploadHandler; 

    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent intent) { 

     if (requestCode == Controller.FILE_SELECTED) { 
      // Chose a file from the file picker. 
      if (mUploadHandler != null) { 
       mUploadHandler.onResult(resultCode, intent); 
      } 
     } 

     super.onActivityResult(requestCode, resultCode, intent); 
    } 

    class MyWebChromeClient extends WebChromeClient { 
     public MyWebChromeClient() { 

     } 

     private String getTitleFromUrl(String url) { 
      String title = url; 
      try { 
       URL urlObj = new URL(url); 
       String host = urlObj.getHost(); 
       if (host != null && !host.isEmpty()) { 
        return urlObj.getProtocol() + "://" + host; 
       } 
       if (url.startsWith("file:")) { 
        String fileName = urlObj.getFile(); 
        if (fileName != null && !fileName.isEmpty()) { 
         return fileName; 
        } 
       } 
      } catch (Exception e) { 
       // ignore 
      } 

      return title; 
     } 

     @Override 
     public boolean onJsAlert(WebView view, String url, String message, final JsResult result) { 
      String newTitle = getTitleFromUrl(url); 

      new AlertDialog.Builder(MainActivity.this).setTitle(newTitle).setMessage(message).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { 

       @Override 
       public void onClick(DialogInterface dialog, int which) { 
        result.confirm(); 
       } 
      }).setCancelable(false).create().show(); 
      return true; 
      // return super.onJsAlert(view, url, message, result); 
     } 

     @Override 
     public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) { 

      String newTitle = getTitleFromUrl(url); 

      new AlertDialog.Builder(MainActivity.this).setTitle(newTitle).setMessage(message).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { 

       @Override 
       public void onClick(DialogInterface dialog, int which) { 
        result.confirm(); 
       } 
      }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int which) { 
        result.cancel(); 
       } 
      }).setCancelable(false).create().show(); 
      return true; 

      // return super.onJsConfirm(view, url, message, result); 
     } 

     // Android 2.x 
     public void openFileChooser(ValueCallback<Uri> uploadMsg) { 
      openFileChooser(uploadMsg, ""); 
     } 

     // Android 3.0 
     public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) { 
      openFileChooser(uploadMsg, "", "filesystem"); 
     } 

     // Android 4.1 
     public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { 
      mUploadHandler = new UploadHandler(new Controller()); 
      mUploadHandler.openFileChooser(uploadMsg, acceptType, capture); 
     } 
    }; 

    class Controller { 
     final static int FILE_SELECTED = 4; 

     Activity getActivity() { 
      return MainActivity.this; 
     } 
    } 

    // copied from android-4.4.3_r1/src/com/android/browser/UploadHandler.java 
    ////////////////////////////////////////////////////////////////////// 

    /* 
    * Copyright (C) 2010 The Android Open Source Project 
    * 
    * Licensed under the Apache License, Version 2.0 (the "License"); 
    * you may not use this file except in compliance with the License. 
    * You may obtain a copy of the License at 
    * 
    *  http://www.apache.org/licenses/LICENSE-2.0 
    * 
    * Unless required by applicable law or agreed to in writing, software 
    * distributed under the License is distributed on an "AS IS" BASIS, 
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
    * See the License for the specific language governing permissions and 
    * limitations under the License. 
    */ 

    // package com.android.browser; 
    // 
    // import android.app.Activity; 
    // import android.content.ActivityNotFoundException; 
    // import android.content.Intent; 
    // import android.net.Uri; 
    // import android.os.Environment; 
    // import android.provider.MediaStore; 
    // import android.webkit.ValueCallback; 
    // import android.widget.Toast; 
    // 
    // import java.io.File; 
    // import java.util.Vector; 
    // 
    // /** 
    // * Handle the file upload callbacks from WebView here 
    // */ 
    // public class UploadHandler { 

    class UploadHandler { 
     /* 
     * The Object used to inform the WebView of the file to upload. 
     */ 
     private ValueCallback<Uri> mUploadMessage; 
     private String mCameraFilePath; 
     private boolean mHandled; 
     private boolean mCaughtActivityNotFoundException; 
     private Controller mController; 
     public UploadHandler(Controller controller) { 
      mController = controller; 
     } 
     String getFilePath() { 
      return mCameraFilePath; 
     } 
     boolean handled() { 
      return mHandled; 
     } 
     void onResult(int resultCode, Intent intent) { 
      if (resultCode == Activity.RESULT_CANCELED && mCaughtActivityNotFoundException) { 
       // Couldn't resolve an activity, we are going to try again so skip 
       // this result. 
       mCaughtActivityNotFoundException = false; 
       return; 
      } 
      Uri result = intent == null || resultCode != Activity.RESULT_OK ? null 
        : intent.getData(); 
      // As we ask the camera to save the result of the user taking 
      // a picture, the camera application does not return anything other 
      // than RESULT_OK. So we need to check whether the file we expected 
      // was written to disk in the in the case that we 
      // did not get an intent returned but did get a RESULT_OK. If it was, 
      // we assume that this result has came back from the camera. 
      if (result == null && intent == null && resultCode == Activity.RESULT_OK) { 
       File cameraFile = new File(mCameraFilePath); 
       if (cameraFile.exists()) { 
        result = Uri.fromFile(cameraFile); 
        // Broadcast to the media scanner that we have a new photo 
        // so it will be added into the gallery for the user. 
        mController.getActivity().sendBroadcast(
          new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, result)); 
       } 
      } 
      mUploadMessage.onReceiveValue(result); 
      mHandled = true; 
      mCaughtActivityNotFoundException = false; 
     } 
     void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { 
      final String imageMimeType = "image/*"; 
      final String videoMimeType = "video/*"; 
      final String audioMimeType = "audio/*"; 
      final String mediaSourceKey = "capture"; 
      final String mediaSourceValueCamera = "camera"; 
      final String mediaSourceValueFileSystem = "filesystem"; 
      final String mediaSourceValueCamcorder = "camcorder"; 
      final String mediaSourceValueMicrophone = "microphone"; 
      // According to the spec, media source can be 'filesystem' or 'camera' or 'camcorder' 
      // or 'microphone' and the default value should be 'filesystem'. 
      String mediaSource = mediaSourceValueFileSystem; 
      if (mUploadMessage != null) { 
       // Already a file picker operation in progress. 
       return; 
      } 
      mUploadMessage = uploadMsg; 
      // Parse the accept type. 
      String params[] = acceptType.split(";"); 
      String mimeType = params[0]; 
      if (capture.length() > 0) { 
       mediaSource = capture; 
      } 
      if (capture.equals(mediaSourceValueFileSystem)) { 
       // To maintain backwards compatibility with the previous implementation 
       // of the media capture API, if the value of the 'capture' attribute is 
       // "filesystem", we should examine the accept-type for a MIME type that 
       // may specify a different capture value. 
       for (String p : params) { 
        String[] keyValue = p.split("="); 
        if (keyValue.length == 2) { 
         // Process key=value parameters. 
         if (mediaSourceKey.equals(keyValue[0])) { 
          mediaSource = keyValue[1]; 
         } 
        } 
       } 
      } 
      //Ensure it is not still set from a previous upload. 
      mCameraFilePath = null; 
      if (mimeType.equals(imageMimeType)) { 
       if (mediaSource.equals(mediaSourceValueCamera)) { 
        // Specified 'image/*' and requested the camera, so go ahead and launch the 
        // camera directly. 
        startActivity(createCameraIntent()); 
        return; 
       } else { 
        // Specified just 'image/*', capture=filesystem, or an invalid capture parameter. 
        // In all these cases we show a traditional picker filetered on accept type 
        // so launch an intent for both the Camera and image/* OPENABLE. 
        Intent chooser = createChooserIntent(createCameraIntent()); 
        chooser.putExtra(Intent.EXTRA_INTENT, createOpenableIntent(imageMimeType)); 
        startActivity(chooser); 
        return; 
       } 
      } else if (mimeType.equals(videoMimeType)) { 
       if (mediaSource.equals(mediaSourceValueCamcorder)) { 
        // Specified 'video/*' and requested the camcorder, so go ahead and launch the 
        // camcorder directly. 
        startActivity(createCamcorderIntent()); 
        return; 
       } else { 
        // Specified just 'video/*', capture=filesystem or an invalid capture parameter. 
        // In all these cases we show an intent for the traditional file picker, filtered 
        // on accept type so launch an intent for both camcorder and video/* OPENABLE. 
        Intent chooser = createChooserIntent(createCamcorderIntent()); 
        chooser.putExtra(Intent.EXTRA_INTENT, createOpenableIntent(videoMimeType)); 
        startActivity(chooser); 
        return; 
       } 
      } else if (mimeType.equals(audioMimeType)) { 
       if (mediaSource.equals(mediaSourceValueMicrophone)) { 
        // Specified 'audio/*' and requested microphone, so go ahead and launch the sound 
        // recorder. 
        startActivity(createSoundRecorderIntent()); 
        return; 
       } else { 
        // Specified just 'audio/*', capture=filesystem of an invalid capture parameter. 
        // In all these cases so go ahead and launch an intent for both the sound 
        // recorder and audio/* OPENABLE. 
        Intent chooser = createChooserIntent(createSoundRecorderIntent()); 
        chooser.putExtra(Intent.EXTRA_INTENT, createOpenableIntent(audioMimeType)); 
        startActivity(chooser); 
        return; 
       } 
      } 
      // No special handling based on the accept type was necessary, so trigger the default 
      // file upload chooser. 
      startActivity(createDefaultOpenableIntent()); 
     } 
     private void startActivity(Intent intent) { 
      try { 
       mController.getActivity().startActivityForResult(intent, Controller.FILE_SELECTED); 
      } catch (ActivityNotFoundException e) { 
       // No installed app was able to handle the intent that 
       // we sent, so fallback to the default file upload control. 
       try { 
        mCaughtActivityNotFoundException = true; 
        mController.getActivity().startActivityForResult(createDefaultOpenableIntent(), 
          Controller.FILE_SELECTED); 
       } catch (ActivityNotFoundException e2) { 
        // Nothing can return us a file, so file upload is effectively disabled. 
        Toast.makeText(mController.getActivity(), R.string.uploads_disabled, 
          Toast.LENGTH_LONG).show(); 
       } 
      } 
     } 
     private Intent createDefaultOpenableIntent() { 
      // Create and return a chooser with the default OPENABLE 
      // actions including the camera, camcorder and sound 
      // recorder where available. 
      Intent i = new Intent(Intent.ACTION_GET_CONTENT); 
      i.addCategory(Intent.CATEGORY_OPENABLE); 
      i.setType("*/*"); 
      Intent chooser = createChooserIntent(createCameraIntent(), createCamcorderIntent(), 
        createSoundRecorderIntent()); 
      chooser.putExtra(Intent.EXTRA_INTENT, i); 
      return chooser; 
     } 
     private Intent createChooserIntent(Intent... intents) { 
      Intent chooser = new Intent(Intent.ACTION_CHOOSER); 
      chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intents); 
      chooser.putExtra(Intent.EXTRA_TITLE, 
        mController.getActivity().getResources() 
          .getString(R.string.choose_upload)); 
      return chooser; 
     } 
     private Intent createOpenableIntent(String type) { 
      Intent i = new Intent(Intent.ACTION_GET_CONTENT); 
      i.addCategory(Intent.CATEGORY_OPENABLE); 
      i.setType(type); 
      return i; 
     } 
     private Intent createCameraIntent() { 
      Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
      File externalDataDir = Environment.getExternalStoragePublicDirectory(
        Environment.DIRECTORY_DCIM); 
      File cameraDataDir = new File(externalDataDir.getAbsolutePath() + 
        File.separator + "browser-photos"); 
      cameraDataDir.mkdirs(); 
      mCameraFilePath = cameraDataDir.getAbsolutePath() + File.separator + 
        System.currentTimeMillis() + ".jpg"; 
      cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(mCameraFilePath))); 
      return cameraIntent; 
     } 
     private Intent createCamcorderIntent() { 
      return new Intent(MediaStore.ACTION_VIDEO_CAPTURE); 
     } 
     private Intent createSoundRecorderIntent() { 
      return new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); 

     } 

    } 

    @Override 
    public void onBackPressed() 
    { 
     WebView webView = (WebView) findViewById(R.id.webview); 
     if(webView.canGoBack()){ 
      webView.goBack(); 
     }else{ 
      super.onBackPressed(); 
     } 
    } 

} 

,這我的佈局main.xml中:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:gravity="fill" 
    android:id="@+id/rel_webpage_whole" 
    android:background="#000000" 
    > 

    <ProgressBar 

     android:layout_width="fill_parent" 
     android:layout_height="5dip" 
     android:layout_alignParentTop="true" 
     style="?android:attr/progressBarStyleHorizontal" 
     android:id="@+id/progressBar" 
     android:max="100" 
     android:background="#228b22" 
     /> 
    <WebView 
     android:id="@+id/webview" 
     android:layout_below="@id/progressBar" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_centerVertical="true" 
     android:layout_centerInParent="true" 

     /> 
</RelativeLayout> 

TNX! :)

+0

當然,該URL將被罰款開除對話框。 – hellena 2014-09-23 02:30:41

+0

你在哪裏叫你pogressBar顯示? – 2014-09-23 02:35:10

+0

我還沒有進度條。 – hellena 2014-09-23 02:43:39

回答

0

您可以使用您的佈局如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity" > 

    <ProgressBar 
     android:id="@+id/progressDialog" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" /> 

    <WebView 
     android:id="@+id/webView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

</RelativeLayout> 

現在在你的代碼

ProgressDialog progressDialog = (ProgressDialog)findViewById(R.id.progressDialog); 
    progressDialog.setTitle("Loading"); 
    progressDialog.setMessage("Your Message"); 
    progressDialog.show(); 

一次加載的網頁視圖內容完成或您的預計操作完成後,

progressDialog.dismiss(); 

如果您想要水平進度對話框

progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); 

,如果你知道在你的線程進步

progressDialog.setProgress(0); 
    progressDialog.setMax(100); 

和Set進展。如果你不知道的進步,

progressDialog.setIndeterminate(true); 
+0

我可以把它放在我的代碼中? – hellena 2014-09-23 03:13:59

+0

它給我的錯誤。 – hellena 2014-09-23 03:21:09

+0

「不可轉換的類型不能轉換android.app.progressdialog android.view.view」 – hellena 2014-09-23 03:23:21

0

初始化進度是這樣的:

ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressDialog); 

這是錯誤的鑄造:

ProgressDialog progressDialog = (ProgressDialog)findViewById(R.id.progressDialog); 
+0

好吧,我添加:ProgressBar progressBar =(ProgressBar)findViewById(R.id.progressDialog); ...但之後呢? – hellena 2014-09-23 04:18:12

0

使用下面的示例代碼:

 WebView view= new WebView(getApplicationContext()); 
     view.setWebViewClient(new WebViewClient(){ 
      ProgressDialog dialog= new ProgressDialog(getApplicationContext()); 


      @Override 
      public void onPageStarted(WebView view, String url, 
        Bitmap favicon) { 
       // TODO Auto-generated method stub 
       dialog.setMessage("Loading please wait"); 
       dialog.show(); 
       super.onPageStarted(view, url, favicon); 
      } 

      @Override 
      public void onPageFinished(WebView view, String url) { 
       // TODO Auto-generated method stub 
       dialog.dismiss(); 
       super.onPageFinished(view, url); 
      } 
     }); 

如果偶然的應用程序崩潰然後在getapplicationContext的地方使用「MainActivity.this」。 希望這會解決你的問題。

我使用下面的代碼顯示對話框:

  private void initWebView(WebView view, String url) { 

    WebSettings settings = view.getSettings(); 
// WebView myWebView = (WebView) findViewById(R.id.webview); 
    view.setWebViewClient(new WebViewClient()); 
    settings.setJavaScriptEnabled(true); 
    settings.setAllowFileAccess(true); 
    settings.setDomStorageEnabled(true); 
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE); 
    settings.setLoadWithOverviewMode(true); 
    settings.setUseWideViewPort(true); 
    settings.setSupportZoom(true); 
    // settings.setPluginsEnabled(true); 
    methodInvoke(settings, "setPluginsEnabled", new Class[] { boolean.class }, new Object[] { true }); 
    // settings.setPluginState(PluginState.ON); 
    methodInvoke(settings, "setPluginState", new Class[] { PluginState.class }, new Object[] { PluginState.ON }); 
    // settings.setPluginsEnabled(true); 
    methodInvoke(settings, "setPluginsEnabled", new Class[] { boolean.class }, new Object[] { true }); 
    // settings.setAllowUniversalAccessFromFileURLs(true); 
    methodInvoke(settings, "setAllowUniversalAccessFromFileURLs", new Class[] { boolean.class }, new Object[] { true }); 
    // settings.setAllowFileAccessFromFileURLs(true); 
    methodInvoke(settings, "setAllowFileAccessFromFileURLs", new Class[] { boolean.class }, new Object[] { true }); 

    view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); 
    view.clearHistory(); 
    view.clearFormData(); 
    view.clearCache(true); 
    view.loadUrl(url); 

    view.setWebViewClient(new WebViewClient(){ 
      ProgressDialog dialog= new ProgressDialog(getApplicationContext()); 

      // suppose Imageview and Webview has visibility gone by default then 

      @Override 
      public void onPageStarted(WebView view, String url, 
        Bitmap favicon) { 
       // TODO Auto-generated method stub 
       //dialog.setMessage("Loading please wait"); 
       //dialog.show(); 
       Imageview.setvisivility(View.VISIBLE); 
       super.onPageStarted(view, url, favicon); 
      } 

      @Override 
      public void onPageFinished(WebView view, String url) { 
       // TODO Auto-generated method stub 
       //dialog.dismiss(); 
       imageview.setvisibility(View.GONE); 
       view.setvisibility(View.VISIBLE); 
       super.onPageFinished(view, url); 
      } 
     }); 

    view.setWebChromeClient(new MyWebChromeClient()); 
    // webView.setDownloadListener(downloadListener); 

}  

現在你Onceate方法;

 String url="http://stackoverflow.com/posts/25986941" 
     WebView v= (Webview)findviewbyId(R.id.webviewid); 
     initWebView(v,url); 
+0

它使我當我運行應用程序...「選擇瀏覽器」屏幕(不打開鏈接) – hellena 2014-09-23 04:36:11

+0

所以我不知道它的幫助... – hellena 2014-09-23 04:42:32

+0

好吧,但我怎麼可以在此webview中打開鏈接? – hellena 2014-09-23 12:39:03

0

使用此代碼,您可以顯示progressdialog到的WebView,當Web視圖頁面加載完成

 public class Activity extends ActionBarActivity { 

     WebView myBrowser; 
     ProgressDialog progress; 

     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 

      setContentView(R.layout.activity_mapwebview); 
      myBrowser = (WebView)findViewById(R.id.mybrowser); 
      myBrowser.setWebViewClient(new WebViewClient() { 

       @Override 
       public void onPageStarted(WebView view, String url, Bitmap favicon) { 
        super.onPageStarted(view, url, favicon); 
        progress = ProgressDialog.show(Activity.this, "Please Wait", "Refreshing"); 
       } 
       @Override 
       public void onPageFinished(WebView view, String url) { 
        if (progress.isShowing()) { 
         progress.dismiss(); 
        } 
       } 
      }); 
      //load saved file 

      Log.e("PAth", getFilesDir().toString()); 
      myBrowser.loadUrl("file:///"+getFilesDir()+"/MySampleFile.html"); 
      myBrowser.getSettings().setJavaScriptEnabled(true); 
      myBrowser.getSettings().setBuiltInZoomControls(true); 

     } 


    } 
+0

tnx !!它的工作,但對話proogres不停止,不隱瞞。 – hellena 2014-09-23 12:14:43

+0

如果它的工作,那麼你可以接受作爲回答 – Rajesh 2014-09-23 12:15:51

+0

它不工作,對話框不隱藏時它的完成加載網址。 – hellena 2014-09-23 12:28:10