【发布时间】:2019-12-05 19:16:15
【问题描述】:
我有 3 个数据库列表,我想将它们合并为一个并将数据显示到列表视图中,如下所示:
vathmoss + " " firstnames + " " +lastnames
现在我只显示名字...
Cursor c = database.rawQuery("Select * From " + PDFDatabaseManager.DATABASE_USERS_TABLE + ";", null);
ArrayList<String> vathmoss = new ArrayList<>();
ArrayList<String> firstnames = new ArrayList<>();
ArrayList<String> lastnames = new ArrayList<>();
while (c.moveToNext()) {
vathmoss.add(c.getString(0));
firstnames.add(c.getString(1));
lastnames.add(c.getString(2));
}
c.close();
final ListView listUser = (ListView) popup.findViewById(R.id.listview_user);
if (!vathmoss.isEmpty() && !firstnames.isEmpty() && !lastnames.isEmpty()) {
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.context, android.R.layout.simple_list_item_1,firstnames);
listUser.setAdapter(adapter);
}
【问题讨论】:
标签: android sql listview merge