Is it possible to set header and footer at ListActivity to be fixed at the top and the bottom, so only the content (list) is scrolling, not also header and footer?
I have both set like this:
View header = getLayoutInflater().inflate(R.layout.list_header, null);
View footer = getLayoutInflater().inflate(R.layout.list_footer, null);
ListView listView = getListView();
listView.addHeaderView(header);
listView.addFooterView(footer);
According to project scenario, this methodology would be better than any other approach, because if you want to customize the header and footer, you can make changes in appropriate header and footer layout. In your layout xml file follow this :
In main.xml
In header.xml
In footer.xml
In Activity, Here
You can do it this way given below:
This is inside of your onCreate() method. It worked for me. give comments if you find any bugs here
You can achieve it by using a custom XML layout in which you will set the layout of your header, footer and list.
Note that to be compatible with
ListActivity
this layout must contain aListView
with the idandroid.R.id.list
:And set it in your
ListActivity
like this: