回收视图,滚动视图内的列表视图
我知道LiveView中视图的回收,我也知道我们不能将列表视图作为滚动视图的子视图,这只会扰乱向上滚动。
我知道使用 LinearLayout 或任何其他视图组并向其中添加组件的解决方法。这是非常可行的,但我喜欢调整我的应用程序,并且在实施解决方法时我想要回收视图
。
如果我膨胀一次并尝试添加该视图,则会发生异常并要求我首先在父级上调用removeView()。
如果有的话,谁能告诉我其他解决方法,或者在这种情况下如何实现回收?
I am aware of recycling of views in LiveView
, I am also aware that we cannot have a listview as a child of scroll view
, which just scrambles the scrolling up.
I know the work around of using LinearLayout
or any other viewgroup and add components to it. Which is much feasible, but I like my app tuned, and I want to recycle views
when I am implementing the workaround.
If I inflate once and try to add that view, an exception occures and asks me first call removeView()
on parent.
Can any one tell me other workaround if there's one, or how can I implement recycling in this scenario ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以通过创建自定义ListView组件并重写dispatchTouchEvent()方法来禁用ListView的滚动。这将允许您将 ListView 嵌入 ScrollView 容器中。看看我的答案:
滚动视图、非滚动列表视图内显示的列表的适配器?
It's possible to disable the scrolling of a ListView by creating a custom ListView component and overriding the dispatchTouchEvent() method. This will let you embed a ListView within a ScrollView container. Take a look at my answer for:
Adapter for a List displayed inside a Scroll View, non-Scrolling List View?