Android 2 个字段到 1 个标签的简单光标

Android simple cursor for 2 field into 1 label

我从 database 中获取一些数据,然后将其显示到 listview 中,并使用 SimpleCursosAdapter 代码:

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);

我要的是加一个字段:

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

并放

"titolo_sezione","titolo_materia" 到同一个标签 R.id.label_materia

哪种方法最好?

最好的解决方案是不使用 SimpleCursorAdapter 并扩展 CursorAdapter。这是一个例子:

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

要使用此方法,您可以创建 custom Adapter 然后使用它。