1

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 from database to this already existing inc. How to achieve it?

Joachim Sauer
  • 278,207
  • 54
  • 523
  • 586
Pattabi Raman
  • 5,514
  • 10
  • 35
  • 59

1 Answers1

4

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);
Community
  • 1
  • 1
Marek Sebera
  • 37,155
  • 34
  • 153
  • 231