ExpandableListView和CheckTextView /复选框之间兼容性的Andr​​oid [英] Android compatibility between ExpandableListView and CheckTextView/Checkbox

查看:257
本文介绍了ExpandableListView和CheckTextView /复选框之间兼容性的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个活动,它具有类的可扩展列表视图,其中一些为子类别。
他们都必须是可检查的。我用子类别,一个checkedTextView。对于类,我用一个TextView和一个复选框,因为当我们点击类别名称,我们需要扩大它(它毕竟是一个可扩展的列表视图!)。
对于选择列表视图是多项选择模式。
该适配器为选中的项目清单,并在getchild / getgroup视图(),我设置的复选框(或checkedtextview)由sparsebooleanarray(的列表视图)给出的状态。
对于每一个复选框,我做的:

I've created an activity, which has an expandable list view of category, and some of them as subcategory. They all need to be checkable. I used for subcategory, a checkedTextView. For category, I used a textView and a checkbox, because when we click on the category name, we need to expand it (it is an expandable list view after all !). For the selection, the listview is on "Multiple Choice Mode". The adapter as the list of checked items, and in the getchild/getgroup view(), I set the checkbox (or the checkedtextview) to the state given by the sparsebooleanarray (of the listview). For each checkbox i do :

holder.checkbox.setOnCheckedChangeListener(new checkListener(groupPosition));

所以,当我选中一个复选框,我知道这是在ListView什么位置。

so when i check a checkbox, i know what position it is in the listview.

不过,我有很多与实现问题(给出的位置不好,等等)。
我用得到flatlistposition扩展列表视图的方法,但我怀疑的扩展列表视图不与choiceMode或选择真正兼容...

But I have a lot of problem with that implementations (the position given is not good, etc). I use the method of expandable list view for get the flatlistposition, but I suspect the expandable list view isn't really compatible with the choiceMode or selection...

这是正确的?难道有人已经有困难得到一个类似的项目工作?

Is this right ? Did somebody already had difficulty to get a similar project working ?

推荐答案

我已经找到了一个职位,说是双向是不相容的,但我不记得在哪里。

I've found a post that say that the two way are incompatible, but I can't remember where.

我坚持我发现,通过关联团体一个布尔数组,并为孩子的二维布尔数组的方式,每点击一个群体或一个孩子将改变布尔联想到的位置。

I stick to the way I found, by associating a boolean array for groups, and a two dimensional boolean array for childs, and each click on a group or a child will change the boolean associate to the position.

这是一个有点沉重,但它的工作原理,我们可以做任何我们想要的。

It's a bit heavy but it works and we can do anything we want.

这篇关于ExpandableListView和CheckTextView /复选框之间兼容性的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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