Here's what you get with Section adapter:
public class Person implements Sectionable { private String name; private String city; public Person(String name, String city) { this.name = name; this.city = city; } public String getName() { return name; } public String getCity() { return city; } // @Override public String getSection() { return city; } /* * when filtering occurs, it is doing a case-insensitive search on toString() * for more complex matching, implement Queryable on your model * */ @Override public String toString() { return name + " " + city; } }
List<Person> persons = new ArrayList<Person>(); persons.add(new Person("Kermit the Frog", "Chicago")); persons.add(new Person("Miss Piggy", "Chicago")); persons.add(new Person("Miss Piggy", "Chicago")); persons.add(new Person("Miss Piggy", "Chicago")); persons.add(new Person("Miss Piggy", "Chicago")); persons.add(new Person("Miss Piggy", "Chicago")); persons.add(new Person("Miss Piggy", "Chicago")); persons.add(new Person("Gonzo", "Chicago")); persons.add(new Person("Mister Rogers", "Pittsburgh")); persons.add(new Person("Leonardo", "New York")); persons.add(new Person("Michelangelo", "New York")); persons.add(new Person("Michelangelo", "New York")); persons.add(new Person("Donatello", "New York")); persons.add(new Person("Raphael", "New York")); persons.add(new Person("Michelangelo", "New York")); persons.add(new Person("Donatello", "New York")); persons.add(new Person("Raphael", "New York")); persons.add(new Person("Michelangelo", "New York")); persons.add(new Person("Donatello", "New York")); persons.add(new Person("Raphael", "New York")); persons.add(new Person("Michelangelo", "New York")); persons.add(new Person("Donatello", "New York")); persons.add(new Person("Raphael", "New York")); persons.add(new Person("Donatello", "New York")); persons.add(new Person("Raphael", "New York")); persons.add(new Person("Captain Crunch", "Orlando")); persons.add(new Person("Soggies", "Orlando")); persons.add(new Person("Pooh Bear", "Hundred Acre Wood")); persons.add(new Person("Eor", "Hundred Acre Wood")); persons.add(new Person("Owl", "Hundred Acre Wood")); persons.add(new Person("Tigger", "Hundred Acre Wood")); persons.add(new Person("Piglet", "Hundred Acre Wood")); persons.add(new Person("Owl", "Hundred Acre Wood")); persons.add(new Person("Tigger", "Hundred Acre Wood")); persons.add(new Person("Piglet", "Hundred Acre Wood")); persons.add(new Person("Owl", "Hundred Acre Wood")); persons.add(new Person("Tigger", "Hundred Acre Wood")); persons.add(new Person("Piglet", "Hundred Acre Wood")); persons.add(new Person("Owl", "Hundred Acre Wood")); persons.add(new Person("Tigger", "Hundred Acre Wood")); persons.add(new Person("Piglet", "Hundred Acre Wood")); adapter.setData(persons); adapter.notifyDataSetChanged();