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

Commit a6d3b3a

Browse files
committed
fix ListView index on click when ListView has no header
1 parent 59b4c94 commit a6d3b3a

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Xamarin.Forms.Platform.Android/CellAdapter.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,12 @@ bool AActionMode.ICallback.OnPrepareActionMode(AActionMode mode, IMenu menu)
132132

133133
public void OnItemClick(AdapterView parent, AView view, int position, long id)
134134
{
135+
var listView = parent as AListView;
136+
if (listView != null)
137+
position -= listView.HeaderViewsCount;
138+
135139
if (_actionMode != null || _supportActionMode != null)
136-
{
137-
var listView = parent as AListView;
138-
if (listView != null)
139-
position -= listView.HeaderViewsCount;
140140
HandleContextMode(view, position);
141-
}
142141
else
143142
HandleItemClick(parent, view, position, id);
144143
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,6 @@ protected override void HandleItemClick(AdapterView parent, AView view, int posi
481481
cell = (Cell)(cellOwner as INativeElementView)?.Element;
482482
}
483483

484-
// All our ListView's have called AddHeaderView. This effectively becomes index 0, so our index 0 is index 1 to the listView.
485-
position--;
486-
487484
if (position < 0 || position >= Count)
488485
return;
489486

0 commit comments

Comments
 (0)