Android:在列表视图行中填充多个项目

时间:2010-03-10 22:16:15

标签: java android listview

我正在尝试填充列表,我的问题是如何将列表行与多个项绑定。到目前为止,我有:

String[] homeLists = getResources().getStringArray(R.array.homeItems); 
setListAdapter(new ArrayAdapter<String>(this, R.layout.home_item, R.id.homeItemName, homeLists));

home_item看起来像这样:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
<TextView android:id="@+id/homeItemName" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp"
    android:textSize="16sp"/>

如果我添加另一个TextView说“homeItemDec”,我如何在setListAdapter调用中绑定homeItemName和homeItemDesc?

1 个答案:

答案 0 :(得分:3)

一旦超出基本列表项,您可能希望开始制作自己的适配器并为每个单元格返回自定义视图。代码示例here

相关问题