
[英]Filling a sectioned RecyclerView using a SortedDictionary, ViewHolders under section not showing
[英]Sectioned list view only showing last section
我有一个基于Jeff Sharkey的实现的分区列表视图。 问题是列表视图仅显示了一个部分(最后一个)。 这是我添加部分的方式:
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);
尝试此操作,因为第一个参数需要与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));
}
如
在代码添加功能是
public void addSection(String section, Adapter adapter) {
this.headers.add(section);
this.sections.put(section, adapter);
}
其中部分是地图
public final Map<String,Adapter> sections = new LinkedHashMap<String,Adapter>();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.