0

I have UI requirement shown below:

|------------------------|
|Header-1                |
|     Checkbox1[]        |
|     Checkbox2[]        | 
|     Checkbox3[]        |
|------------------------|
|Header-2                |
|     Checkbox1 []       |
|     Checkbox2 []       |
|     Checkbox3 []       |

and so on clicking below button. BUTTON -> clicking on this button on bottom will create header and 3 checkbox everytime. How can i achieve this? This is very urgent. I can not take these in XML laypout as these need to be added dynamically on runtime.

If possible, Please provide any sample code and guide me.

Thanks, Rachana

1 Answers1

0

You should create a listView containing rows defined by a layout having :

  • a linear layout containing a textView with Header-1 (and so on) as text
  • another linearLayout containing three checkboxes.

You will create an arrayAdapter with a list of strings representing different values for Header-1 (I guess checkboxes will have same values all the time).

Adding a click listener (onClickListener) on your button. This listener will add an item to the arrayList used by the adapter to add new items in /remove items from your listview when your arrayList is modified (calling notifyDataSetChanged()) to refresh the listView.

Jeremy D
  • 4,787
  • 1
  • 31
  • 38
  • Hi Jeremy, Thank you for your quick response. Can you please send me code? – user1163581 Jan 22 '12 at 16:29
  • Hi Jeremy, Please send me code, it is very urgent, I am working on weekends for my project release and have many things to do in plate, If possible send me the code. I will be great full to you. – user1163581 Jan 22 '12 at 16:48
  • Hi Jeremy, I managed to display UI as per your suggestion, but now my problem is i am not able to find out which row chcekbox belongs when i clicked on checkbox. Lets say I clicked on first checkbox of second listbox item so i should somehow get that checkbox we clicked belongs to second listbox item – user1163581 Jan 24 '12 at 11:05