Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Android] Fix for Talkback reporting incorrect number of list items (#4090) #10151

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System.Collections.Generic;

#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.ManualReview)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 4090, "Talkback reports incorrect number of list items", PlatformAffected.Android)]
public class Issue4090 : TestContentPage // or TestMasterDetailPage, etc ...
{
protected override void Init()
{
// Initialize ui here instead of ctor

List<string> menuItems = new List<string>
{
"Browse","About"
};

StackLayout stack = new StackLayout();

ListView ListViewMenu = new ListView();
ListViewMenu.ItemsSource = menuItems;

ListViewMenu.SelectedItem = menuItems[0];

Label label = new Label();
label.Text = "When clicking 'Browse' or 'About', Talkback should report that the element is in list of 2 items";
stack.Children.Add(label);
stack.Children.Add(ListViewMenu);
Content = stack;


BindingContext = new ViewModelIssue4090();
}
}

[Preserve(AllMembers = true)]
public class ViewModelIssue4090
{
public ViewModelIssue4090()
{

}
}

[Preserve(AllMembers = true)]
public class ModelIssue4090
{
public ModelIssue4090()
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue11311.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue8291.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue2674.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue4090.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue6484.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue6187.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue3228.xaml.cs">
Expand Down Expand Up @@ -2276,4 +2277,4 @@
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
</Project>
16 changes: 16 additions & 0 deletions Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,15 @@ void UpdateFooter()
}

if (footer == null)
{
if (_footerView.ChildCount == 0)
{
AListView nativeListView = Control;
nativeListView.RemoveFooterView(_adapter.FooterView);
}
return;
}


if (_footerRenderer != null)
_footerRenderer.SetElement(footer);
Expand Down Expand Up @@ -391,7 +399,15 @@ void UpdateHeader()
}

if (header == null)
{
if (_headerView.ChildCount == 0)
{
AListView nativeListView = Control;
nativeListView.RemoveHeaderView(_adapter.HeaderView);
}
return;
}


if (_headerRenderer != null)
_headerRenderer.SetElement(header);
Expand Down