填充时刷新布局
我有一个带有 HorizontalScrollView
的活动。当它打开时,我开始用另一个视图填充此视图(或者更确切地说,其中的容器布局)。这是使用 handler.post
从另一个线程完成的。
视图以 15 个为一组添加,当没有更多视图可添加时,我开始用新数据更新它们(这是一种来自服务器的流数据)。
问题是滚动视图是空的,直到添加所有视图。一旦它们全部添加并开始更新,滚动视图就会被绘制。
添加视图的过程中如何刷新?我不希望在添加所有视图时屏幕空出 3 秒。
多谢。
更新:事实证明,这个问题并不是特定于HorizontalScrollView
,任何通用布局都是如此。
I have an activity with a HorizontalScrollView
. When it opens, I start filling this view (or rather, a container layout inside it) with another views. This is done from another thread by using handler.post
.
The views are added in bunches of 15, and when there are no more views to add, I start updating them with new data (this is a kind of streaming data from a server).
The problem is that the scrollview is empty until all of the views are added. As soon as they are all added and start updating, the scrollview gets drawn.
How do I refresh it in the process of adding views? I don't want the screen to be empty for 3 seconds while all of the views are added.
Thanks a lot.
UPDATE: turned out this problem is not specific for HorizontalScrollView
, this is the case for any generic layout.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定我是否准确理解您的程序是如何构建的,因此在您开始更新之前不会显示视图......但也许 myLayout.forceLayout() 有帮助?
Im not sure I understand exactly how your program is constructed, so that the views are not shown until you start updating... but perhaps myLayout.forceLayout() helps?
当然,布局仅在 onCreate()之后显示。
我可以想象您使用 AsyncTask 来执行数据查找并使用该类中提供的回调来更新 UI,因为它们在主线程上运行。这样你就可以完成 onCreate(),然后开始更新你的视图。
The thing is ofcourse that layout only gets shown after onCreate().
I could imagine you use a AsyncTask to perform data lookup and use the callbacks provided in that class to update the UI, since they run on the main thread. This way you can just finish the onCreate(), and then start updating your view.