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
Developer
Posts: 163
Registered: ‎04-28-2012
My Device: BlackBerry 9800
My Carrier: BlackBerry

How to know the index or index path of the current visible list item in List View?

Hi,

 

     I want to know the indexpath of the current visible list item in the ListView.Please help me.

 

Regards,

Naresh Kodumuri.

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: How to know the index or index path of the current visible list item in List View?

there are more then one items visible - do you mean the selected ListItem ?

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: How to know the index or index path of the current visible list item in List View?

to know the selected ListItem in QML:

 onTriggered: {
    if (selected) {

 then you have access to indexPath so you can get values from your DataModel like

roomsListPage.headerTitle = fileGroupDataModel.data(indexPath).name

 or you call C++ and use indexPath from C++ to do your work

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 163
Registered: ‎04-28-2012
My Device: BlackBerry 9800
My Carrier: BlackBerry

Re: How to know the index or index path of the current visible list item in List View?

Hi ekke,

   

               Thanks for ur reply.The listitem height is total screen height so that at a time only one item will be visible  and i want to know that list item index path with out triggering the list item(i will perform scrolling only).

 

Regards,

Naresh.

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: How to know the index or index path of the current visible list item in List View?

unfortunately there's currently no API to get the first visible item in a List

 

you can vote for an Issue I submitted some time ago

 

https://www.blackberry.com/jira/browse/BBTEN-219

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How to know the index or index path of the current visible list item in List View?

This is a crude hack, but you can try saving the indexPath in ListItemProvider's updateItem function for last updated item.

 

But if item's height is equal to screen height then there can be TWO visible items at the same time during scrolling. Smiley Happy

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 163
Registered: ‎04-28-2012
My Device: BlackBerry 9800
My Carrier: BlackBerry

Re: How to know the index or index path of the current visible list item in List View?

Hi,

 

      Thank u all for ur replies.Now i will try to implement ListItemProvider.Meanwhile if u have done example can u please provide it.

 

Regards,

Naresh Kodumuri.