When my Activity loads, I inflate a layout file that I use for a footer. I attach it to the ListView (addFooterView) and then set its visibility to View.GONE. I maintain a reference to it, and when I want the user to see it, I set the visibility to View.VISIBLE.
For the most part, this works great. However, the footer seems to still take up space. If the user uses the scroll wheel/pad, the area the footer is taking up gets highlighted. I’d like to polish this more so the footer is completely gone; ideally without detaching it from the ListView.
Is this possible? Or am I going to have to set/unset the foot instead of simply toggling its visibility?
You can use
listView.removeFooterView(view). The easiest way to do this is to create an instance variable to hold your inflated footer view (so you only inflate it inonCreate()). Then just calllistView.addFooterView(instanceFooter)andlistView.removeFooterView(instanceFooter)as needed.Edit:
Here’s what I’m doing to get this to work:
onCreateaddFooterView()THEN initialize your adapter (keep an instance reference to it) and callsetAdapter(). This will leave theListView“prepped”notifyDatasetChanged()removeFooterView()(it will hide it if it’s being displayed and do nothing otherwise)addFooterView()if the footer needs to be displayed