Android
Android

Reputation: 9023

How do I display a two-line list view?

I want a two-line list view in my activity.

This code is displaying one column. Here only the Category column displays, but I also want the Distance_from_Centre at right side. My code is:

if (c.moveToFirst()) {
    int i = 0;
    do {
        i++;
        int Category = c.getColumnIndex("Category");
        int Distance_from_Centre = c
                .getColumnIndex("Distance_from_Centre");
        String str;
        String Str1;
        str = c.getString(Category).toString();
        Str1 = c.getString(Distance_from_Centre).toString();
        /* strArr1[i] = c.getString(Category).toString();
        strArr2[i] = c.getString(Distance_from_Centre).toString();*/
        list.add(str);

        Log.i("LOCATION ", str);
        Log.i("I  ", i + "");
    } while (c.moveToNext());
    lv.setAdapter(new ArrayAdapter<String>(this,
            android.R.layout.test_list_item, list));
    // android.R.layout.simple_list_item_1,list));
}

Upvotes: 0

Views: 358

Answers (2)

MACMAN
MACMAN

Reputation: 1971

Use android.R.layout.two_line_list_item

Upvotes: 0

Vineet Shukla
Vineet Shukla

Reputation: 24031

You need to customize your list adapter.

Upvotes: 1

Related Questions