在为 Android 活动创建视图时显示进度对话框
在 Android 活动中,我在构建报告(视图)方面有一个漫长的过程。我想在创建视图时显示一个进度对话框“正在构建报告..请稍候”。是否可以启动活动(屏幕切换),然后显示进度对话框,然后呈现视图?
我想或者我可以在主活动的后台线程上构建视图,同时显示进度对话框,然后一旦创建视图,我就可以启动下一个活动并呈现构建的视图。
处理此类问题的最佳方法是什么,即在构建复杂视图时显示反馈?视图必须用代码构建,而不是 XML,并且随着数据的迭代,它可能需要几秒钟。我希望应用程序看起来响应迅速。
谢谢。
In an android activity I have a lenghty process in building a report (view). I would like to show a progress dialog "Building Report..Please Wait" while the view is being created. Is it possible to start and activity (screen switch) and then show a progress dialog and then present the view?
I guess alternatively I could build the view on a background thread from the main activity while showing a progress dialog and then once the view is created I could start the next activity and present the built view.
What is the best way to handle something like this, i.e. show feedback while a complex view is being built? The view has to be built in code, not XML, and with the iterations of the data it can be a few seconds. I want the application to appear responsive.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我明白了这一点。我显示进度对话框,然后启动一个后台任务,该任务在 RunOnUiThread 元素中具有 setcontentView 并隐藏进度对话框。
I figured this out. I show the progress dialog and then start a background task which has the setcontentView in the RunOnUiThread element and hide the progress dialog.