0

I have a sectioned list view based on Jeff Sharkey's implementation. The problem is only one section of the list view is showing (the last one). Here's how I add the sections:

SeparatedListAdapter adapter = new SeparatedListAdapter(this);

for (int i = 0; i < groups.size(); ++i)    // groups is an ArrayList<ArrayList<Person>>
{
    ArrayList<Person> group = groups.get(i);
    adapter.addSection("Section test", new MyCustomAdapter(this, R.layout.custom_cell, group));
}

ListView listView = (ListView) findViewById(R.id.myListView);
listView.setAdapter(adapter);
jmosesman
  • 716
  • 1
  • 11
  • 24

1 Answers1

1

try this as need first argument different from previous one in addSection

for (int i = 0; i < groups.size(); ++i)    // groups is an ArrayList<ArrayList<Person>>
{
    ArrayList<Person> group = groups.get(i);
    adapter.addSection("Section test"+i, new MyCustomAdapter(this, R.layout.custom_cell, group));
}

as

in code add function is

public void addSection(String section, Adapter adapter) {
this.headers.add(section);
this.sections.put(section, adapter);
}

where sections is a Map

public final Map<String,Adapter> sections = new LinkedHashMap<String,Adapter>();
Dheeresh Singh
  • 15,643
  • 3
  • 38
  • 36
  • 1
    Doh! You are right. I wasn't thinking of the section title as the section key so it was overwriting it every time. Thanks! – jmosesman Jun 25 '12 at 19:31