Question

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));

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

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 ?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top