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 List
s 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
精彩评论