我是Android新手。请帮帮我。我有两个字符串数组如下:Android - 字符串数组到ListView
String[] Array1 = {"ele1", "ele2", "ele3", "ele4", "ele5", "ele6"};
String[] Array2 = {"obj1", "obj2", "obj3", "obj4", "obj5", "obj6"};
我在我的布局如下列表视图:
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/lytlistView"
android:layout_marginTop="4dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_below="@+id/lytListView">
</ListView>
现在,我要为ListView控件添加两个字符串数组的值显示在下面:
-------------------------
listHeader1
listContent1
-------------------------
listHeader2
listContent2
-------------------------
listHeader3
listContent3
-------------------------
所以,listHeader[1,2,3,..]
包含Array1[]
元素和listContent[1,2,3,....]
包含Array2[]
元素
我该如何做到这一点?请帮帮我。
您需要使用hashmap进行映射。 – Unknown 2013-04-29 05:50:52
使用自定义列表视图http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html – rajeshwaran 2013-04-29 05:52:32
尝试阅读[本博客文章](http ://bartinger.at/listview-with-sectionsseparators/)关于分段列表视图 – thepoosh 2013-04-29 06:04:17