【问题标题】:How to add items in two columns in Listview (Android)?如何在 Listview (Android) 的两列中添加项目?
【发布时间】:2012-01-24 06:20:41
【问题描述】:

我在Listview工作过,我在arraylist1和arraylist2中存储了值,然后从arraylist1,arraylist2中检索值,然后插入这两个arraylists值 在每一行,如何?请问谁能帮帮我?

谢谢

例子:

arraylist1 - 23/1/12
arraylist2 - welcome

这两个值是在Listview中插入的

ListView - 23/1/12     welcome

【问题讨论】:

标签: android listview


【解决方案1】:

您可以使用Multicolumn ListView in Android。并在

中添加您的数组列表值
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
map.put("Value1", arrayList1.get(0));
map.put("Value2", arrayList2.get(0));
mylist.add(map);

【讨论】:

  • lv1.setAdapter(new ArrayAdapter(DocketCalc.this,android.R.layout.simple_list_item_1 , mylist));
  • 是的,因为您需要一个资源 ID,它显示这些字符串,如果可能的话,使用与示例链接中提供的相同的适配器。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-18
相关资源
最近更新 更多