Aaron
Aaron

Reputation: 1161

Custom adapter in Android

I would like to make a custom CursorAdapter that takes a cursor and provides an extra summary row at the end. Such that given a Cursor with 4 rows, the ListView will contain 5 rows, the 4 rows from the cursor, plus a fifth row that contains some totals from the previous 4 rows. From the documentation I'm not clear on which methods to override to get this done. Or maybe there's a better way to do this..

Upvotes: 0

Views: 2885

Answers (2)

CommonsWare
CommonsWare

Reputation: 1006664

Mr. Munoz's answer is good. Another option, instead of changing the Cursor, is to use addFooterView() to add another row on your list that does not come from your Cursor data.

Upvotes: 2

Franklin Munoz
Franklin Munoz

Reputation: 917

You can easily accomplish this by using the MergeCursor class, pass the original cursor as the first element on the array to the constructor and create a new simple AbstractCursor subclass that returns only the one item you are appending and pass it as the second element for the array in the constructor. Everything should work automatically for you then.

Upvotes: 1

Related Questions