1

After running a query. Cursor have result like this(I am only giving 4 here)

ID | Name | Topic|
------------------
1  | A    | Poster
------------------
1 | B     | Poster
------------------
2 | C      | Presentation
-------------------------
2 | D      | Presentation

Now, All I want to show A & B and C & D on a same cell in listview. How can I do that?

is there any way to get data like this way.

1
  • Where do you get the Data, from SQLITE? Commented Jul 26, 2013 at 11:39

4 Answers 4

1

you can just get the data from the cursor as strings and merge them as you like before you save them in the listview.

String example = (cursor.getString(0) + "," + cursor.getString(1)); cursor.moveToPosition(id);
example = example + (cursor.getString(0) + "," + cursor.getString(1));
ArrayList<String> listItems = new ArrayList<String>();
listItems.add(example);

Sign up to request clarification or add additional context in comments.

Comments

1

You can use this code it is working for me.

c.moveToFirst();
        if (c != null) {
            do {
                for (int i = 0; i < c.getColumnCount(); i++) {

                    Log.e("", "" + c.getString(i));
                }
            }while (c.moveToNext());
        }

Comments

0

GROUP BY Topic in your SQL query and join A, B manually. I don't think you can use the cursor directly

Comments

0

You need to create a bean for listitem object that will contain same type of items then develop a custom listview adaptor for that item in order to archive that goal.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.