1

In my android application I want simple list which should be initially blank when I add item it would my root list item. Further, when I add more item in that list it all should be under that root list item and it should keep number of item added under that root list .

How can I achieve this?

RivieraKid
  • 5,923
  • 4
  • 38
  • 47
Daxx
  • 13
  • 1
  • 3
  • see this complete example http://android-example-code.blogspot.in/p/dynamic-custoized-list-view-in-android.html – MAC May 08 '12 at 11:57

3 Answers3

0

If you want nested items then your best bet is to use the ExpandableListView http://developer.android.com/reference/android/widget/ExpandableListView.html

If you want more than one level of nesting then I do not believe there is anything out-of-the-box to achieve this.

Ian Warwick
  • 4,774
  • 3
  • 27
  • 27
0

Have a look this answer listView dynamic add item

In this code we are add data at run time.

first of all we set the an empty adapter to listview after that at run time we add the new item on button click

Community
  • 1
  • 1
Ashish Dwivedi
  • 8,048
  • 5
  • 58
  • 78
0

Just use an ArrayAdapter to show items on the list. When you need to add items just add them to the array and call notifyDataSetChanged();

Bush
  • 2,433
  • 5
  • 34
  • 57