Search code examples
androidsimplecursoradapter

Android simple cursor for 2 field into 1 label


I get some data from a database and I show it into a listview, with a SimpleCursosAdapter whit this code:

SimpleCursorAdapter adapter = new SimpleCursorAdapter(App.getAppContext(),R.layout.list_view_row,c,
                new String[] { "titolo_testo","titolo_sezione","text" },
                new int[] { R.id.label_testo , R.id.label_materia , R.id.label_testo }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

what I want is to add a field:

new String[] { "titolo_testo","titolo_sezione","titolo_materia","text" } 

and put

"titolo_sezione","titolo_materia" into the same label R.id.label_materia

which is the best way for do it?


Solution

  • The best solution would be don't use SimpleCursorAdapter and extend CursorAdapter. Here is an example:

    http://www.gustekdev.com/2013/05/custom-cursoradapter-and-why-not-use.html