本文介绍了Android的进度条没有被驳回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用进度对话框显示进度的同时加载网页,但有时不能正常工作。进度对话框永远不会被解雇,虽然加载页面。

我添加进度条是这样

 公共布尔shouldOverrideUrlLoading(web视图查看,字符串URL){
    //添加进度对话框
}

公共无效onPageFinished(web视图查看,字符串URL){
    如果(progressdialog.isShowing())
       progressdialog.dismiss(); //驳回进步,但有时从来没有驳回
}
 

解决方案

android_dev,使用一个处理器

 公共无效onPageFinished(web视图查看,字符串URL)
    {
    handler.sendEmptyMessage(0);
    }

    处理程序处理程序=新的处理程序(){
      @覆盖
      公共无效的handleMessage(信息MSG){
     如果(progressdialog.isShowing()|| progressdialog!= NULL)
     progressdialog.dismiss();
     progressdialog = NULL;
      }
    }
 

&放大器;你做!

I am using Progress Dialog to show progress while loading web page, but sometimes it does not work properly. Progress Dialog never get dismissed though page is loaded.

I have added Progress Bar like this

public boolean shouldOverrideUrlLoading(WebView view, String url) {
    //Added progress dialog
}

public void onPageFinished(WebView view, String url) {
    if(progressdialog.isShowing())
       progressdialog.dismiss(); //Dismissed the progress, but sometimes never dismiss it
}
解决方案

android_dev , Use a handler

    public void onPageFinished(WebView view, String url) 
    { 
    handler.sendEmptyMessage(0);
    }

    Handler handler = new Handler() {
      @Override
      public void handleMessage(Message msg) {
     if(progressdialog.isShowing() || progressdialog!=null)
     progressdialog.dismiss();
     progressdialog=null;
      }
    }

& you are done!

这篇关于Android的进度条没有被驳回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 15:31