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 r开发者_StackOverflowight 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));
}
You need to customize your list adapter.
Use android.R.layout.two_line_list_item
精彩评论