After reading Dynamically add elements to a listView Android , I understand clearly how to dynamically add row
elements to a listView.
However, I have one idea that how to dynamically add column
elements to a listview.
For example, there are 2 columns originally. After I click a button, I would like to add one one more column.
Can anyone provide example code?
Thank for all sharing.
Asked
Active
Viewed 1,330 times
1
-
ListView in android is single column, I would assume by adding column, you mean replacing the views with a layout contain additional item? – Yenchi Jul 17 '12 at 15:00
1 Answers
1
Just add rows dynamically, but make a custom view with two different elements... So there'll be two elements on your every view of row. And first, set first items while seconds are invisible and after clicking button set others... So it'll seem that you're adding column...

yahya
- 4,810
- 3
- 41
- 58
-
-
2You should have a view with two item, what item you want. Let's say two textViews. And you need to use custom arrayAdapter. First, you should set first textViews on every raw's view. And then on click you should notify your arrayAdapter to set second textViews on every raw... – yahya Jul 17 '12 at 15:16
-
-
Simply, they can be set as half screen width for each... Or however it's wanted. Depends on the app's requirement... – yahya Jul 18 '12 at 06:52