Documentation says listViewObj.addView() method is not supported. I want to add view to the end of the list without refreshing it. How this can be done?
Asked
Active
Viewed 1.6k times
2 Answers
8
You can add a footer to the ListView by,
View footerView = getLayoutInflater().inflate(R.layout.footer_layout, null);
listview.addFooterView(footerView);

Lalit Poptani
- 67,150
- 23
- 161
- 242
-
well without refreshing listview how a new view could be added? that won't be possible. – Lalit Poptani Apr 17 '12 at 13:15
-
OK. If I have a list view which contains image view with remote location(loading imageview from url). Would it again fetch images from url on adding new view at the end of the list? – AndroidDev Apr 17 '12 at 13:22
-
1If you are doing the code for fetching image from url in the adapter class then yes it will fetch again, so in that case you can use LazyList of Fedor. – Lalit Poptani Apr 17 '12 at 13:24
-
LazyList of Fedor?? Do you have any reference to it. And is it possible to add view at particular position in the listview? – AndroidDev Apr 17 '12 at 13:46
-
This is a link to [Fedor's LazyList](http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012) – Lalit Poptani Apr 18 '12 at 04:26
-
Yes but you have to refresh ListView for adding it. – Lalit Poptani Apr 18 '12 at 05:19
1
If you want to add a view outside your list use addFooterView, see http://developer.android.com/reference/android/widget/ListView.html#addFooterView(android.view.View)
If you want the view to be part of the list than you will have to refresh it. The new data must be added in the adapter and notify that data changed, see http://developer.android.com/reference/android/widget/BaseAdapter.html#notifyDataSetChanged()

azertiti
- 3,150
- 17
- 19