Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android add view in listview

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?

like image 492
AndroidDev Avatar asked Jan 17 '23 22:01

AndroidDev


2 Answers

You can add a footer to the ListView by,

View footerView = getLayoutInflater().inflate(R.layout.footer_layout, null);
listview.addFooterView(footerView);
like image 172
Lalit Poptani Avatar answered Jan 20 '23 04:01

Lalit Poptani


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()

like image 23
azertiti Avatar answered Jan 20 '23 04:01

azertiti