在执行大型方法时在 android 中显示进度对话框
我有一个在 onCreate 期间调用的长时间运行的方法,该方法填充文本视图,以便与 UI 交互,并更新可能 70 个标签(大约 3-20 秒,具体取决于设备)。
我想在执行此方法时显示一个进度对话框。
理想情况下,一旦显示 Activity 并显示进度,我想在 UI 线程上触发我的方法,但我不能这样做,Activity 在方法完成之前不会绘制。
我希望找到一个在活动显示后触发的事件,我找到了下面的事件,但它仍然使屏幕保持黑色,直到该方法完成。
@覆盖 public void onPostCreate(Bundle savingInstanceState)
我通常是一名 WP7 开发人员,在 .NET 中,您为 onLoadComplete 添加一个事件处理程序,该事件处理程序在显示 ui 之后但在用户有机会与 UI 交互之前触发,我该怎么做这个在Android JAVA中吗?
谢谢
I have a long running method that is called during onCreate, this method populates textviews so interacts with the UI, and updates maybe 70 labels (about 3-20 seconds depending on device).
I want to display a progressdialog as this method executes.
Ideally I want to fire my method on the UI thread once the Activity has been displayed and the progress is displayed, this I cannot do, the Activity won't paint until the method has finished.
I hoped to find an event which was fired after the activity was displayed, and I found the one below, but it still leaves the screen black until the method has finished.
@Override
public void onPostCreate(Bundle savedInstanceState)
I am normally a WP7 developer, and in .NET you add an event handler for onLoadComplete which is fired after the ui is displayed, but before the user has a chance to interact withthe UI, how do I do this in Android JAVA?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在视图中放置一个进度条。
然后在 onCreate() 或 onResume() 方法中执行以下操作:
现在您可以在方法中执行此操作来更新进度条
Put a ProgressBar in the View.
Then in the onCreate() or onResume() method do this:
Now you can do this inside your method to update the progressBar