Skip to content

Instantly share code, notes, and snippets.

@relict007
Last active January 4, 2016 08:19
Show Gist options
  • Save relict007/8595086 to your computer and use it in GitHub Desktop.
Save relict007/8595086 to your computer and use it in GitHub Desktop.
Merge 2 adapters in Android
/*
* source: https://stackoverflow.com/questions/6754973/how-to-insert-extra-elements-into-a-simplecursoradapter-or-cursor-for-a-spinner/14622789#14622789
*/
MatrixCursor extras = new MatrixCursor(new String[] { "_id", "title" });
extras.addRow(new String[] { "-1", "New Template" });
extras.addRow(new String[] { "-2", "Empty Template" });
Cursor[] cursors = { extras, cursor };
Cursor extendedCursor = new MergeCursor(cursors);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment