【问题标题】:Android simple cursor for 2 field into 1 label2个字段到1个标签的Android简单光标
【发布时间】:2026-01-13 15:40:01
【问题描述】:

我从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

最好的方法是什么?

【问题讨论】:

    标签: android simplecursoradapter


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

      【讨论】: