- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
进度条不更新。然而,它在任务完成时结束。
int totalSms = 12;
int currentSms = 0;
public class ProgressTask extends AsyncTask<String, Integer, Boolean> {
/** progress dialog to show user that the backup is processing. */
private ProgressDialog dialog;
public ProgressTask(ScanInboxActivity activity) {
dialog = new ProgressDialog(activity);
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setMax(totalSms);
}
protected void onPreExecute() {
dialog.setMessage("Scan start");
dialog.show();
}
@Override
protected void onProgressUpdate(Integer... values) {
Log.d(TAG, "in onProgressUpdate: " + values[0]); // shows actuall count in the log
dialog.setProgress(values[0]); // does not update
//tried even this, does not work
//dialog.incrementProgressBy(values[0]);
}
@Override
protected void onPostExecute(final Boolean success) {
if (dialog.isShowing()) {
dialog.dismiss();
}
populateList();
}
protected Boolean doInBackground(final String... args) {
try {
Context context = getApplicationContext();
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(context);
while (currentSms < totalSms) {
Thread.sleep(1000);
currentSms++;
publishProgress(currentSms);
}
} catch (IllegalArgumentException e) {
} catch (InterruptedException e) {
}
return true;
}
最佳答案
dialog.setIndeterminate(true);
应该是false
,否则加载值不会被计算
关于Android ProgressBar 不更新 onProgress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17166250/
我已经实现了从 Internet 下载文件的代码,但在使用进度值(进度百分比)更新 GUI 线程时遇到空指针异常。 这是我的代码。 public class CustomviewActivity e
我正在尝试使用 ajax 实现带有上传百分比的标签。问题是xhr返回100%后,到readyState==4和status==200还需要17秒左右。 我正在使用 FormData() 对象发送图片
我正在使用 XmlHttpRequests 将图像上传到服务器,我想向用户显示这些上传的进度。 不幸的是,调用我的 onprogress-event 处理程序之间的间隔太大。通常,对于 500k 的图
进度条不更新。然而,它在任务完成时结束。 int totalSms = 12; int currentSms = 0; public class ProgressTask extends AsyncT
我正在使用 XmlHttpRequests 将图像上传到服务器,我想向用户显示这些上传的进度。 不幸的是,对我的 onprogress-event 处理程序的调用之间的间隔太大。对于 500k 的图像
我正在尝试使用 HTML5 制作一个带有进度表的文件 uploader 。这是我的代码: Test Progress Meter function submit
当发送带有 async = false 的 XMLHttpRequest 时,xhr.upload.onprogress 事件永远不会在文件上传时触发。 来源: var form = new Form
我有以下 AJAX 代码,脚本将文件正确上传到服务器(node express)。我面临的问题是 onProgress 仅在下载总字节时(因此在文件上传结束时)触发,而不是在其进度期间触发。 目前我无
Fine Uploader 的 onProgress() 回调在 Android 设备上不起作用。这是我的代码: onProgress: function(id, fileName, loaded,
我在获取在 chrome 上工作的音频标签的 onprogress 事件时遇到问题。它似乎适用于火狐。 http://www.scottandrew.com/pub/html5audioplayer/
您的浏览器如何决定触发 FileReader.onprogress 事件的频率?我在这个事件中做了一些处理,我认为它比我想要的更频繁地触发。我想要更大的 block 。有没有办法告诉它少开火? 示例代
我在通过 XHR 上传文件时订阅了 onProgress 事件。我的进度条是动画的(通过 jQuery)以提供更好的视觉美感。 onProgress 似乎触发得非常快,所以我想知道它实际触发的频率,以
除了永远不会触发 xhr.upload.onprogress 事件之外,以下代码中的所有内容都可以正常工作。 $(function(){ var xhr; $("#submit").c
我目前正在尝试构建一个 ajax 图像 uploader ,除了一个重要部分之外,我让它可以正常工作。 对于我上传的每个单独文件,我想更新该文件的进度条。目前它只更新最后一个文件的进度条。
如何确保在加载模型时定期更新加载进度,以便我可以构建加载图标。我已经跟踪了我能找到的每一个图例,但对于每个答案,onProgress 方法只会在加载完成后触发一次。 我的 typescript 加载器
我有一个 React 应用程序来播放来自后端的一些视频。为了播放视频,我集成了 npm 模块react-azure-mp 作为 Azure 媒体播放器的包装模块。根据 Azure 媒体播放器文档,有一
简短版: 我想得到 this与this一起工作: 长版: 我想创建一个 jQuery 扩展,它向 $.ajax 对象添加一个进度方法,并与 IE8 和 IE9 的 XDomainRequest 对象一
我正在尝试使用两个拇指搜索栏 我正在使用 This - PROJECT MainActivity.java public class MainActivity extends Activity {
您好,我在为场景加载纹理时生成加载消息时遇到了一些问题。 onProgress console.log 消息仅在纹理完全下载时触发,而不是在下载期间触发。 manager = new THREE.
问题 我有一个页面,用户可以在 FormData 和 XMLHttpRequest 的帮助下上传文件。上传文件工作正常。但是 upload.onprogress 仅在从 HTTP 连接上传时起作用。
我是一名优秀的程序员,十分优秀!