填充时刷新布局

发布于 2024-09-08 18:36:23 字数 395 浏览 1 评论 0原文

我有一个带有 Horizo​​ntalScrollView 的活动。当它打开时,我开始用另一个视图填充此视图(或者更确切地说,其中的容器布局)。这是使用 handler.post 从另一个线程完成的。

视图以 15 个为一组添加,当没有更多视图可添加时,我开始用新数据更新它们(这是一种来自服务器的流数据)。

问题是滚动视图是空的,直到添加所有视图。一旦它们全部添加并开始更新,滚动视图就会被绘制。

添加视图的过程中如何刷新?我不希望在添加所有视图时屏幕空出 3 秒。

多谢。

更新:事实证明,这个问题并不是特定于Horizo​​ntalScrollView,任何通用布局都是如此。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

俏︾媚 2024-09-15 18:36:24

我不确定我是否准确理解您的程序是如何构建的,因此在您开始更新之前不会显示视图......但也许 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?

む无字情书 2024-09-15 18:36:24

当然,布局仅在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文