I am trying to insert list items dynamically into the list view. As list view is created and displayed on the screen now suppose i got one items from the server or some where, now i want to add this item in the same list view what i have displayed. How to do that ?? Is there any way to insert items dynamically in the displayed list view without creating the list agtain and again. And is there any way to change the status of list item, that means can we interact while it is displaying?? your’s reply will be appreciated. Thnx in advance !!
Share
Add whatever you want to the data structure (meaning the
List) that is being used by yourAdapterand then callnotifiyDataSetChanged()on yourAdapterWith a regular
ArrayAdapterit would be something like:I can provide a more complicated example with a
BaseAdapteras well.EDIT
I created a little sample because this question seems to be pretty common.
In my sample I did everything in one class, just to make it a bit easier to follow it all in one place.
In the end, it’s very much a model-view-controller type situation. You can even run the actual project by cloning it from here: https://github.com/levinotik/Android-Frequently-Asked-Questions
The essence of it is this:
If you grasp the concept here, you should be able to adapt (no pun intended) this to ArrayAdapters, etc.