请帮助我,在我的情况下如何ListView
添加Subitem
?
我有list_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/back_black" >
<ImageView
android:id="@+id/icon"
android:layout_width="30dp"
android:layout_height="40dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:src="@drawable/ic_launcher" >
</ImageView>
<TextView
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text=""
android:textColor="@color/yellow"
android:textSize="20sp" >
</TextView>
<TextView
android:id="@+id/sublabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text=""
android:textColor="@color/white"
android:textSize="12sp" />
</LinearLayout>
我需要从Subitem
数据库中添加几行(HOME_COLUMN
、CITY_COLUMN
、STREET_COLUMN
等)。我只R.id.label
从数据库中添加了一个项目()只有一行(NAME_COLUMN
)
private void fillData() {
String[] from = new String[] { KvartDB.NAME_COLUMN };
int[] to = new int[] { R.id.label };
//how to add R.id.sublabel a few lines from the database ?
adapter = new SimpleCursorAdapter(this, R.layout.list_row, null, from,
to, 0);
setListAdapter(adapter);