Closed DrBeak1 closed 8 years ago
There is not a convenience method for this. One way would by a while loop.
i = sectionPosition
while (true) {
if (isSection(i)) break;
i++;
}
int size = (i - 1) - sectionPosition;
This is just quick and off the top of my head solution, on my cell phone. I'll leave this issue open and will add a convenience method but it will probably only be in 2.+ or maybe 1.+. We'll see.
Awesome, thanks Chris - I appreciate your response.
@DrBeak1 In class that extends SectionCursorAdapter Introduce global array list
ArrayList<Integer> sectionIndeces = new ArrayList<>();
Override buildsections
@Override protected SortedMap<Integer, Object> buildSections(Cursor cursor) {
SortedMap<Integer, Object> sections = super.buildSections(cursor);
sectionIndeces.clear();
sectionIndeces.addAll(sections.keySet());
return sections;
}
make method to get count for specific section
private int getSectionSize(int position) {
int count;
int index = sectionIndeces.indexOf((Integer) position);
if (index < sectionIndeces.size() - 1) {
count = sectionIndeces.get(index + 1) - sectionIndeces.get(index) - 1;
} else {
count = super.getCount() - sectionIndeces.get(index) - 1;
}
return count;
}
@DrBeak1 used your method but added the ability of getting it for any index in the section using the list position. Big changes in 3.0.
I've been looking through the source but cannot find a way to get the count for a particular section. Is this possible?
Thanks in advance for any help.