Thank you for visiting the BlackBerry Support Community Forums.
BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)
BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.
"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."
- Kevin Michaluk, Founder, CrackBerry.com
Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.
11-23-2012 04:42 AM
I have made a listfield by extending a Vertical manager where i am adding number of Horizontal manager.The HFM contains an image and a Text.Now the thing is that i want to get the index of the row when i click it.The problem is that for the first row it gives me 0 which is correcnt,but for the 2nd row it gives me 2 instead of 1,same for 3rd it gives 4 instead of 2.Please help
Solved! Go to Solution.
11-23-2012 05:09 AM
Just to avoid confusion, what you seem to have created is not a ListField, which is a completely different UI component than a series of HFMs added to a VFM.
You seem to be using getFieldIndex() on the VFM. If all you had added were the HFM, then I would expect the indexes to go up by one. The fact that they go up by 2 indicates that you have added something else, like a NullField. So I would check your code to confirm which Manager you are getting the Field index from and what else you add to that Manager.
11-23-2012 05:49 AM
And which Manager is this getting the index for?
In my experience, the Indexes don't lie. The fact that it appears to be wrong would suggest a logic error in this approach.
The debugger is your Friend here. But split the statement up so you can check all components, say
Field focusField = getLeafWithFocus();
Manager focusManager = focusField.getManager();
Manager focusManagerManager = focusManager.getManager();
int focusIndex = focusManager.getIndex();
System.out.println("Focused on: " + focusField.toString() + " in " + focusManager.toString() + ", which is in: " + focusManagerManager.toString() + " at index: " + focusIndex);