安卓:在的ListView性能Horizo​​ntalScrollView问题 [英] Android: ListView in HorizontalScrollView performance issues

查看:146
本文介绍了安卓:在的ListView性能Horizo​​ntalScrollView问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的应用程序的一些数据水平和垂直滚动。我重写 Horizo​​ntalScrollView ,我已经允许它采取适配器来填充数据。它的行为很像水平的ListView会表现,但我没有做任何看法回收。在我的自定义 Horizo​​ntalScrollView 每一项都是一个的ListView ,其项目也填充了一个适配器。在的ListView 每个项目是一个复杂的视图。

I have a need for both horizontal and vertical scrolling of some data in my app. I've overridden HorizontalScrollView and I've allowed it to take an Adapter to populate its data. It behaves much like a horizontal ListView would behave, except I'm not doing any view recycling. Each item in my custom HorizontalScrollView is a ListView whose items are also populated with an Adapter. Each item in the ListView is a complex view.

我可以水平滚动,而只是它的表现是有点矮胖的垂直就好了。在适配器的getView()方法用于填充自定义 Horizo​​ntalScrollView 适配器首先设置上只调用视图。然而,我注意到,getView()正在不断呼吁列表视图中的 Horizo​​ntalScrollView 。我不知道是这是性能问题?

I'm able to scroll horizontally, and vertically just fine except that it's performance is a bit chunky. The getView() method in the adapter for populating the custom HorizontalScrollView is only called when the Adapter is first set on the view. However, I noticed that getView() is constantly being called for the ListViews in the HorizontalScrollView. I'm wondering is this is the performance problem?

<一个href=\"http://stackoverflow.com/questions/4825086/horizontalscrollview-with-listview-documentation-bug\">This问题指出关于使用里面的 Horizo​​ntalScrollView ,但同样的一个的ListView一个所谓的文档错误警告未对垂直滚动滚动型文档的文档中给出​​。

This question points out a supposed documentation bug pertaining to using a ListView inside of a HorizontalScrollView, but the same warning is not given in the documentation for the vertically scrolling ScrollView documentation.

我将有性能问题,如果我把ScrollViews的Horizo​​ntalScrollView内?

Will I have performance issues if I put ScrollViews inside of the HorizontalScrollView?

推荐答案

的ListView 的松弛度值 layout_height 做的伎俩。没有设置一个高度引起的ListView 来保持测量,调用getView等。

Giving the ListView a dip value for layout_height did the trick. Not setting a height was causing the ListView to keep measuring, calling getView, etc.

这篇关于安卓:在的ListView性能Horizo​​ntalScrollView问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆