Thank you for guiding the way. After trial-and-error, I got it.
Anyway, since I'm used to helping people on the Internet, I know there
is nothing worse than having someone say "I got it right", and not
posting the solution. Or even worse: not posting an explanation of the
solution. So here it is for those searching Google. For the header:
private View header (String caption) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
TextView tv = (TextView) View.inflate(
this, R.layout.tide_header, null);
tv.setText(caption);
return tv;
}
Calling from onCreate:
adapter.addView(header("Section 1"), false);
...
adapter.addView(header("Section 2"), false);
For the rows... each row/item is an
ArrayList<HashMap<String,Object>>(). After "put"ting each HashMap into
the ArrayList, we get a "row". Then, do the same process for each row
in the section. Example:
rowList = new ArrayList<HashMap<String,Object>>();
HashMap<String, Object> hashMap;
// START REPEATING HERE, for each item in a row
hashMap= new HashMap<String, Object>();
hashMap.put(ITEM_NAME, "David");
hashMap.put(ITEM_HEIGHT, "1.82");
hashMap.put(ITEM_LEVEL, R.drawable.ic_level03);
rowList .add(hm);
// END REPEATING HERE
PeopleAdapter ta = new PeopleAdapter(rowList, this);
adapter=new MergeAdapter();
adapter.addView(header("Family 1"), false);
adapter.addAdapter(ta);
adapter.addView(header("Family 2"), false);
...
The Adapter is the easiest part. You can use pretty much any adapter
you currently use (if you ever did a custom XML, single level List,
you'll know).
Best regards everyone. And thanks Mark Murphy! Your help may not have
sounded much to you, but it certainly was to me.
David
On Apr 16, 5:52 pm, Mark Murphy <
mmur...@commonsware.com> wrote:
> You would inflate the header XML yourself using LayoutInflater and add
> that to the MergeAdapter using addView(). You would use the row
> adapter with an ArrayAdapter (or whatever sort of adapter you want),
> adding that to the MergeAdapter using addAdapter().
>
> --
> Mark Murphy (a Commons Guy)
http://commonsware.com|
http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy