Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
munknex
Posts: 8
Registered: ‎02-03-2013
My Device: Simulator
Accepted Solution

Idiomatic way to get item displayed in ListView

[ Edited ]

I have a ListView with a StackListLayout and SnapMode.LeadingEdge. ListItemComponent fills entire ListView, so there is only one item displayed at a time (except animations). 

 

What is the idiomatic way to get the indexPath of displayed item?

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Idiomatic way to get item displayed in ListView

In recent SDK versions firstVisibleItem property appeared in ListScrollStateHandler. I did not try to use it yet. There's also firstVisibleItemChanged signal:

 

https://developer.blackberry.com/cascades/reference/bb__cascades__listscrollstatehandler.html#firstv...

 

What I'm currently using for similar task is attaching LayoutUpdateHandlers to all list items and tracking their updates to determine which item is the most visible one. But the items stop sending updates when going off-screen. I also had to use a timer to stop tracking off-screen items. If the first approach won't work I can give more details on this one.

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
New Contributor
munknex
Posts: 8
Registered: ‎02-03-2013
My Device: Simulator

Re: Idiomatic way to get item displayed in ListView

Thanks, ListScrollStateHandler is what I need.
Please use plain text.