gpt4 book ai didi

java - Android:在 ListView 行中填充多个项目

转载 作者:行者123 更新时间:2023-12-02 00:52:31 24 4
gpt4 key购买 nike

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

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 调用中绑定(bind) homeItemName 和 homeItemDesc?

最佳答案

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

关于java - Android:在 ListView 行中填充多个项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2421060/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com