如何在Android中添加多个List <string>?</string>

时间:2011-10-03 06:39:14

标签: java android

如何在Android中分配多个列表?

List<String> inc = dh.selectInct1();
    ArrayAdapter<String> inc1 = new ArrayAdapter<String>(this,R.layout.list,R.id.textViewx,inc);
    lvinc.setAdapter(inc1);
lvinc.setOnItemClickListener(this);

此处dh.selectInct1();会返回分配到inc的列表。现在我需要从数据库中再添加一个列表到现有的inc。如何实现呢?

1 个答案:

答案 0 :(得分:4)

只需使用List

加入这两个addAll(Collection c)即可
List<String> inc = dh.selectInct1();
List<String> inc2 = dh.selectInct2();  //select your data to second list
inc.addAll(inc2); // join them together
ArrayAdapter<String> inc1 = new ArrayAdapter<String>(this,R.layout.list,R.id.textViewx,inc);
lvinc.setAdapter(inc1);
lvinc.setOnItemClickListener(this);