我有一个基于Jeff Sharkey's实现的分段列表视图。问题是列表视图中只有一部分显示(最后一部分)。以下是我添加部分的方法:
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);
答案 0 :(得分:1)
尝试将此作为第一个参数,与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
代码添加功能是
public void addSection(String section, Adapter adapter) {
this.headers.add(section);
this.sections.put(section, adapter);
}
其中sections是Map
public final Map<String,Adapter> sections = new LinkedHashMap<String,Adapter>();