从Cursor到一个listview元素的Concat结果
|
我有一个android listview,它具有two_line_list_item布局。...text1和text2
我有一个SQL查询,它返回我的Cursor ....在下面的示例中,我将NameA从SQL设置为text1,将NameB设置为text2。
// Create an array to specify the fields we want to display in the list (only TITLE)
String[] from = new String[]{\"NameA\", \"NameB\"};
// and an array of the fields we want to bind those fields to (in this case just text1)
int[] to = new int[]{android.R.id.text1, android.R.id.text2};
// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter matches = new SimpleCursorAdapter(this, android.R.layout.two_line_list_item, MatchesCursor, from, to);
setListAdapter(matches);
我该如何串联两个名称(不更改我的SQL查询),以便text1为\“ NameA v NameB \” ...
提前致谢
没有找到相关结果
已邀请:
4 个回复
粳饶瓢部
然后删除第二个textView(android.R.text2) 在返回投影中,将\“ NameAB \”放在其他列中(保留KEY_ID),因为您将不再需要它们。
晤默报
篮肥炼皖
将所有内容包装在水平LinearLayout中。
旗低饶彤
的自己的适配器
现在,您需要做的就是修改数据库访问函数的一部分,以返回两个名称数组,并将它们传递给ѭ5the的构造函数。 最后,致电:
请注意,也请尝试遵循链接中建议的ViewHolder模式。