Skip to content

Commit 7f06705

Browse files
committed
remove header and footer of ListView when they are empty
taken from PR xamarin#10151
1 parent 15ec2fe commit 7f06705

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,14 @@ void UpdateFooter()
365365
}
366366

367367
if (footer == null)
368+
{
369+
if (_footerView.ChildCount == 0)
370+
{
371+
AListView nativeListView = Control;
372+
nativeListView.RemoveFooterView(_adapter.FooterView);
373+
}
368374
return;
375+
}
369376

370377
if (_footerRenderer != null)
371378
_footerRenderer.SetElement(footer);
@@ -397,7 +404,14 @@ void UpdateHeader()
397404
}
398405

399406
if (header == null)
407+
{
408+
if (_headerView.ChildCount == 0)
409+
{
410+
AListView nativeListView = Control;
411+
nativeListView.RemoveHeaderView(_adapter.HeaderView);
412+
}
400413
return;
414+
}
401415

402416
if (_headerRenderer != null)
403417
_headerRenderer.SetElement(header);

0 commit comments

Comments
 (0)