0

How can we create multiple listview dynamically in single activity please provide me any code....

androidGuy
  • 5,553
  • 12
  • 39
  • 56
shripal
  • 1,222
  • 4
  • 19
  • 40
  • multiple listview means ? 2 or more listviews in one screen ? – sat Mar 28 '11 at 05:21
  • yes...i want to show more than 2 listviews in one screen and every listview should have heading... – shripal Mar 28 '11 at 05:28
  • can u provide any sample screenshot? – Pinki Mar 28 '11 at 05:31
  • Demo of List View listone: Basic Information --> name,address,about me. listtwo: Education--> collage,course,year listthree: Contact Information--> phone no, mobile no,city, country. – shripal Mar 28 '11 at 05:39

1 Answers1

1

Create 2 Linear layouts side by side , say orientation as horizontal(give id's to the layout) , create a listview dynamically in code and attach those 2 listviews to your layouts.

like,

Listview lv1 = new ListView();   
ListView lv2 = new ListView();

// get reference to your layouts    
LinearLayout lL1 = (LinearLayout) findViewById(R.id.layoutId1);    
LinearLayout lL2 = (LinearLayout) findViewById(R.id.layoutId2);

// attach the ListView objects to the LinearLayouts
lL1.addview(lv1);   
lL2.addview(lv2);

This should get you started.

Kingsolmn
  • 1,868
  • 2
  • 23
  • 39
sat
  • 40,138
  • 28
  • 93
  • 102
  • I am getting lists from the webservice show and that list will be dynamic that means it may be 2 3 or more than that. so, i have to create listview dynamically.... – shripal Mar 28 '11 at 05:37
  • Its better to fix some fixed layouts before you can populate the results. – sat Mar 28 '11 at 05:40
  • can you provide me some demo code of "dynamically create listview"?? – shripal Mar 28 '11 at 05:43
  • Dynamically creating listview is similar to as I have shown in the soln , I am not sure what you are looking after , to add rows dynamically to listview , you can check here http://stackoverflow.com/questions/1917773/dynamic-listview-in-android-app – sat Mar 28 '11 at 05:46
  • i am looking for "add more than one listview with respective contents not only content" – shripal Mar 28 '11 at 05:49
  • Demo of List View listone: Basic Information --> name,address,about me. listtwo: Education--> collage,course,year listthree: Contact Information--> phone no, mobile no,city, country – shripal Mar 28 '11 at 05:49