How to show header of ListView when its empty

android, android-layout, android-listview

Solution

So this is how I solved it. I had a custom adapter which was connected to the listview. When it found that it had zero items to display. It would add a fake empty view as an item to the list.

Problem

I am developing the following screen The fourboxes next to each other are buttons. On clicking of the buttons I am changing the adapter of the listview. Since the content above the listview took up lot of space I made the whole thing as an header and added it via code. ``` myPollsList = (ListView) findViewById(R.id.listArea); myPollsList.addHeaderView(getLayoutInflater().inflate(R.layout.profile_listview_header, null)); ``` Now I want to show some view when the list is empty. But if I do that then the header also goes away. I am using this in a Activity and not a ListActivity. Any suggestions or workarounds for showing the header even when the list is empty ? EDIT: Refer to my earlier question here ListView not getting space to show content on smaller screens . This is where someone suggested me to solve the problem by putting it as a header

Original source