Back to project page AbstractGroupedAdapter.
The source code is released under:
Copyright (c) 2013 Aryan Ghassemi. All rights reserved. https://github.com/aryaxt/AbstractGroupedAdapter Permission is hereby granted, free of charge, to any person obtaining a copy of this software...
If you think the Android project AbstractGroupedAdapter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.aryaxt.groupedadapter; /* ww w .ja v a 2 s . c o m*/ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.widget.ListView; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView listView = (ListView)this.findViewById(R.id.listview); Map<String, List<Person>> data = new HashMap<String, List<Person>>(); List<Person> aPersons = new ArrayList<Person>(); aPersons.add(new Person("Aryan")); aPersons.add(new Person("Alex")); aPersons.add(new Person("Andrew")); data.put("A", aPersons); List<Person> bPersons = new ArrayList<Person>(); bPersons.add(new Person("Bob")); bPersons.add(new Person("Bastard")); bPersons.add(new Person("Banana")); bPersons.add(new Person("Brandon")); data.put("B", bPersons); MyAdapter adapter = new MyAdapter(this); adapter.setData(data); listView.setAdapter(adapter); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }