开发者

How to add more than one List<String> in Android?

How to assign more than one List in 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);

Here dh.selectInct1(); returns a list that is assigned into inc. Now I need to add one more list fro开发者_开发知识库m database to this already existing inc. How to achieve it?


Simply join those two Lists using 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);
  • How do I join two lists in Java?
  • List.addAll() documentation
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜