How to show header of ListView when its empty

后端 未结 4 1086
鱼传尺愫
鱼传尺愫 2020-12-10 18:01

I am developing the following screen

\"enter

The fourboxes next to each other

相关标签:
4条回答
  • 2020-12-10 18:47

    Don't use top layouts of button as header for list view.

    So to adjust UI without using list header use weights.

    Give parent Linear layout weight sum as 4 and 1, 1 to top Layouts and 2 for list view.

    0 讨论(0)
  • 2020-12-10 18:51

    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.

    0 讨论(0)
  • 2020-12-10 18:55

    maybe you will like this Android addHeaderView disappears when no items in ListView

    override/subclass your adapter to return false from isEmpty()

    0 讨论(0)
  • 2020-12-10 18:57

    I found a simple solution for this problem. If there's no elements for list and you are not adding the adapter, just add this:

    mListView.setAdapter(null);
    

    and the header will appear. It's easier than adding empty / fake item to the list.

    0 讨论(0)
提交回复
热议问题