6String_Coder 6String_Coder - 6 months ago 105
Android Question

FireMonkey TListView click/press behaviour

I have a Firemonkey Listview in an app running on both iOS and Android. The listview contains 5 items.

One thing I've noticed is when I press the list view with my finger but not on an actual item (in the blank space below the last item), it still selects/highlights the last item in the listview.

Is there anyway of preventing this?



The issue is in the FMX.ListView.pas unit file.

There is a function called

function TCustomListView.FindItemAbsoluteAt(ViewAt: Integer): Integer;

Need to replace

if ViewAt >= FHeightSums[FHeightSums.Count - 1] then
Exit(FHeightSums.Count - 1);


if ViewAt >= (FHeightSums[FHeightSums.Count - 1] + GetItemHeight(FHeightSums.Count - 1)) 
then Exit(-1);

Once this has been changed, save and add the unit file to your project and it should work.