如何从一个ListView所有儿童(有形和无形)? [英] How to get all children (visible and invisible) from a ListView?

查看:160
本文介绍了如何从一个ListView所有儿童(有形和无形)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是类似<一个href="http://stackoverflow.com/questions/6766625/listview-getchildat-returning-null-for-visible-children">ListView getChildAt返回可见儿童空,但尽管搜索,我不能找到一个解决方案。

My problem is similar to ListView getChildAt returning null for visible children, but despite searching I cannot find a solution.

我有一个的ListView 有滚动。该的ListView 有10个项目,其中7个是可见和3隐藏滚动。我也有一个外部方法(从适配器),必须得到所有从这个的ListView 的孩子(例如,使用 getChildAt())。

I have a ListView with a Scroll. The ListView has 10 items, 7 of which are visible and 3 are hidden by scroll. I also have an external method (out of adapter) that must get all of the children from this ListView (e.g. using getChildAt()).

我需要的物品全部10,但最后3是的对象。我试过code这样的:

I need all 10 of the items, but the last 3 are null objects. I've tried code like the following:

getListView().smoothScrollToPosition();

但是,这并不正常工作。

But this doesn't work.

我想我并不需要张贴我​​的code休息,作为描述说的一切吗?

I think that I don't need to post the rest of my code, as the description says everything?

推荐答案

正如你已经看到的,你不能从一个的ListView 仅仅是因为所有的子行的意见一个的ListView 只保存为可见行的意见(加上一些回收行,但你不能达到的)。做你想做什么是正确的方法是,无论数据存储在适配器的数据,并从那里取回它。

As you have already seen you can't get all the child row views from a ListView simply because a ListView holds only the views for the visible rows(plus some recycled rows but you can't reach those). The correct way to do what you want is to store whatever data in the adapter's data and retrieve it from there.

但在ListView不会从RadioGroup中保持当前值   运行时间。

But the ListView doesn't keep the current values from RadioGroup in running time.

我已经看到了,你有一些问题,这让我已经适应了一些旧的code建立一个基本的例子,code,你可以的在这里找到

I've seen that you have some problems with this so I've adapted some old code to build a basic example, code that you can find here.

这篇关于如何从一个ListView所有儿童(有形和无形)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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