I’m using a ListActivity with a Checkbox through an ArrayAdapter.
What I’m trying to do is adding ListView items dynamically with a different layout (TextView only) when the checkBox gets checked.
Also it should disappear after getting un-checked again too.
CheckBox unchecked:
+----------------------+
| cb -- some text -- |
+----------------------+
| - new Heading - |
+----------------------+
| etc. |
+----------------------+
CheckBox checked:
+----------------------+
| cb -- some text -- |
+----------------------+
| --- TextView --- |
+----------------------+
| --- TextView --- |
+----------------------+
| - new Heading - |
+----------------------+
| etc. |
+----------------------+
What’s the best way to accomplish this?
You can do this as follows:
Another simplar approach is to define the TextViews from the begining and let the checkbox set their visibility instead.