简体   繁体   English

在为 android 活动创建视图时显示进度对话框

[英]Showing a progress dialog while creating view for android activity

In an android activity I have a lenghty process in building a report (view).在 android 活动中,我在构建报告(视图)方面有一个漫长的过程。 I would like to show a progress dialog "Building Report..Please Wait" while the view is being created.我想在创建视图时显示一个进度对话框“Building Report.. Please Wait”。 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, ie 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.视图必须在代码中构建,而不是 XML,并且随着数据的迭代,它可能需要几秒钟。 I want the application to appear responsive.我希望应用程序显示响应。

Thank you.谢谢你。

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.我显示进度对话框,然后启动在 RunOnUiThread 元素中有 setcontentView 的后台任务并隐藏进度对话框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM