显示加载/进度指示器的最佳方式? [英] Best way to show a loading/progress indicator?

查看:29
本文介绍了显示加载/进度指示器的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用等待服务器响应时显示加载微调器的最佳方式是什么?

What is the best way to show a loading spinner while the app is waiting for a response from the server?

这可以以编程方式完成吗?这样我就不必在 xml 文件中添加加载微调器了?

Can this be done programmatically? So that I don't have to add the load spinner in the xml file?

推荐答案

ProgressDialog 已从 Android Oreo 中弃用.改用 ProgressBar

ProgressDialog is deprecated from Android Oreo. Use ProgressBar instead

ProgressDialog progress = new ProgressDialog(this);
progress.setTitle("Loading");
progress.setMessage("Wait while loading...");
progress.setCancelable(false); // disable dismiss by tapping outside of the dialog
progress.show();
// To dismiss the dialog
progress.dismiss();

ProgressDialog.show(this, "Loading", "Wait while loading...");

在此处阅读更多信息.

顺便说一下,Spinner 在 Android 中有不同的含义.(就像 HTML 中的选择下拉菜单)

By the way, Spinner has a different meaning in Android. (It's like the select dropdown in HTML)

这篇关于显示加载/进度指示器的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆