Answer the question
In order to leave comments, you need to log in
How to list multiple columns from a database in one row of a ListView?
Good day to all! I have a database in which there are a lot of different columns, for example, there is a list of cats:
Name Age Gender Favorite toy City of residence, etc.
Vasya, 2 years old, ball Moscow ....
Actually, the essence of the problem, for example, we have a lot of cats and I need to flip through them, that is, use the ListView method, how to make each cat appear like this:
Vasya, 2 years old, m, ball, Moscow, . ..,...,...
Musya, 3 years old, f, wand, Moscow,..,...,...,
if there is a chance to do better, then it would be more ideal:
name: Vasya, age: 2 years old, gender: m, toy: ball, city: Moscow, ...,...,...
name: Musya, age: 3 years old, gender: f, toy: stick, city: Moscow,..,...,...,
I have the following code
String[] headers = new String[]{DatabaseHelper.COLUMN_NAME , DatabaseHelper.COLUMN_YEAR, DatabaseHelper.COLUMN_CITY, DatabaseHelper.COLUMN_STREET, DatabaseHelper.COLUMN_HOME,
DatabaseHelper.COLUMN_FILM, DatabaseHelper.COLUMN_GAME};
// create adapter, pass cursor to it
userAdapter = new SimpleCursorAdapter(this, android.R.layout.two_line_list_item,
userCursor, headers, new int[]{android.R.id.text1, android.R.id.text2}, 0);
userList.setAdapter(userAdapter);
I understand that I need to somehow change the Simple CursorAdapter, but I don’t understand how to fix it
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question