在Android的按一下按钮进度对话框 [英] Progress dialog on button click in android
本文介绍了在Android的按一下按钮进度对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想提出一个Android应用程序中,我有android.I使用进度对话框要加载进度图像时,我在登录点击button.Actully我解析响应,我希望到时的响应被解析它应该显示进度dialog.Any帮助将AP preciated。
谢谢你。
I am making an android app in which i have to use progress dialog in android.I want to load progress image when i clicked on login button.Actully i am parsing response and i want till the time the response gets parsed it should show progress dialog.Any help will be appreciated. Thanks.
推荐答案
是的,你可以这样做code以下和纽带。
http://developer.android.com/reference/android/os/AsyncTask.html
Yes you can do that like code below and link. http://developer.android.com/reference/android/os/AsyncTask.html
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
protected Long doInBackground(URL... urls) {
int count = urls.length;
long totalSize = 0;
for (int i = 0; i < count; i++) {
totalSize += Downloader.downloadFile(urls[i]);
publishProgress((int) ((i / (float) count) * 100));
}
return totalSize;
}
protected void onProgressUpdate(Integer... progress) {
setProgressPercent(progress[0]);
}
protected void onPostExecute(Long result) {
showDialog("Downloaded " + result + " bytes");
}
}
这篇关于在Android的按一下按钮进度对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文