【发布时间】:2011-01-24 13:11:45
【问题描述】:
我是 Android 新手,我想我正在尝试做一些非常基本的事情:我的数组中有 5 个字符串(比如“一”、“二”...)。我想在我的 listactivity 中将这 5 个字符串添加到我的列表视图中。
我的清单:
<ListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
我的列表行:
<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="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
基本上,我想将 Array 项绑定到 TextView homeItemName。稍后我可能会在我的行中添加其他项目,所以我不能只将列表视图绑定到条目。
谢谢!
【问题讨论】:
-
您需要对适配器和 ArrayAdapters 有基本的了解。您可能必须扩展这些类之一。
标签: java android arrays listview