Android:使用 dbhelper 创建大型数据库时更新水平进度对话框
我已经找这个好几天了。我有一个非常大的数据库,它是从 SQL 文件加载的。其代码位于 DbHelper 类文件中,因此,当我创建帮助程序的实例时,如果数据库不存在,则会进行创建。
我显示了一个进度微调器,但我希望能够显示一个进度条,该进度条随着文件的创建而递增。
大多数示例展示了如何执行此操作,但没有展示如何将值从助手发送回主活动。
从 main 中的线程调用助手。任何帮助将不胜感激
I have been searching for this for days. I have a very large database which is loaded from an SQL file. The code for this is in the DbHelper class file and so, as I create an instance of the helper, if the database does not exist the creation takes place.
I have a progress spinner showing but I would like to be able to show a progress bar which increments as the file is created.
Most examples show how to do this but not how to send a value from the helper back to the main activity.
The helper is called from a thread in main. Any help would be greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 AsyncTask 做得很好的事情。
当您从 doInBackground 内部调用publishProgress 方法时,将在UI 线程上调用onProgressUpdate 方法,您可以从那里更新进度栏。
这里有几个很好的例子:
http://labs.makemachine.net/2010/05/android-asynctask-示例/
https://sites .google.com/site/androidhowto/how-to-1/create-a-custom-progress-bar-using-asynctask
This is something that an AsyncTask does very well.
When you invoke the publishProgress method from inside doInBackground, the onProgressUpdate method gets called on the UI thread and you can update your progress bar from there.
Here's a couple of good examples:
http://labs.makemachine.net/2010/05/android-asynctask-example/
https://sites.google.com/site/androidhowto/how-to-1/create-a-custom-progress-bar-using-asynctask