开发者

android listview empty message with header

开发者 https://www.devze.com 2023-01-08 14:56 出处:网络
Is there any way t开发者_如何学Co display the empty message and the listview header at the same time?It seems that when i set the empty view and the list is empty, the header will not be displayed.

Is there any way t开发者_如何学Co display the empty message and the listview header at the same time? It seems that when i set the empty view and the list is empty, the header will not be displayed.

thx Ben


Ugh, yeah, this is the wrong behavior in my opinion. But for better or worse, that's the way Android works.

I would advise creating a custom view and putting it in the table's footer instead. Keep a reference to the view in your activity, and set it's visibility to View.VISIBLE or View.GONE depending on what the list adapter returns in is isEmpty().


I believe because, ListView takes up all space, and therefore when you're header is empty it'll be so small that your ListView just goes over it. if you get what I mean??

Perhaps, you could try to make a check when the View is empty, to push a text in it with something random just to see if it's really there.

Or

You make a SumWeight where the header always get's a percentage of your screen regardless of being empty or not.


You can have a listview and a textview underneath.So when there is listitem in your listview,your textview can be made invisible.and when your listview is empty,just invisible listview and let the textview be visible.This is the simplest way and I am using the same!

0

精彩评论

暂无评论...
验证码 换一张
取 消