且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ProgressDialog 已弃用

更新时间:2023-11-24 12:08:04

Android O 文档中提到:

As it is mentioned in Android O documentation:

该类在 API 级别 26 中已弃用.ProgressDialog 是一个模态对话框,它阻止用户与应用程序交互.反而使用此类时,您应该使用进度指示器,例如ProgressBar,可以嵌入到您的应用程序的 UI 中.或者,您可以使用通知来通知用户任务的进度.

This class was deprecated in API level 26. ProgressDialog is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like ProgressBar, which can be embedded in your app's UI. Alternatively, you can use a notification to inform the user of the task's progress.

您可以使用 TextView 和 ProgressBar 创建自定义视图并管理其可见性.您可以使用 这个库,因为它使用 AlertDialog 而不是 ProgressDialog.

You can create a custom view with TextView and ProgressBar and manage its visibilty. You can use this library also because it is using AlertDialog instead of ProgressDialog.