将进度微调器插入启动画面Android

将进度微调器插入启动画面Android,第1张

概述在我的android应用程序中,我想放置一个进度条,以便它向用户显示数据正在下载,并且一旦加载数据便被删除.有什么办法可以实现这一目标.提前致谢:)解决方法:您可以通过AsyncTask类来实现.在这三个步骤中,您必须遵循>您必须在onPreExecute()中启动ProgreesDialog.>doInBackground

在我的android应用程序中,我想放置一个进度条,以便它向用户显示数据正在下载,并且一旦加载数据便被删除.

有什么办法可以实现这一目标.

提前致谢:)

解决方法:

您可以通过AsyncTask类来实现.

在这三个步骤中,您必须遵循

>您必须在onPreExecute()中启动ProgreesDialog.
> doInBackground()控制下载进度.
> onPostExcecute()在第二步之后运行.这样您就可以关闭进度对话框,启动“新活动”并完成启动画面.

有关更多信息,请检查Documentation.它带有示例代码的说明.

码:

  private class Task extends AsyncTask<VoID, VoID, VoID> {    private final ProgressDialog dialog = new ProgressDialog(            your_class.this);    // can use UI thread here    protected voID onPreExecute() {        this.dialog.setMessage("Loading...");        this.dialog.setCancelable(false);        this.dialog.show();    }    @OverrIDe    protected VoID doInBackground(VoID... params) {        try {            // do downloading images code here        } catch (Exception e) {        }        return null;    }    protected voID onPostExecute(VoID result) {           //start the another activity and then close your current activity here.        if (this.dialog.isShowing()) {            this.dialog.dismiss();        }    }}
总结

以上是内存溢出为你收集整理的将进度微调插入启动画面Android全部内容,希望文章能够帮你解决将进度微调器插入启动画面Android所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1069483.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存