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

Java Development


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.


Reply
New Contributor
Posts: 5
Registered: ‎04-20-2010
My Device: 8700
My Carrier: o2
Accepted Solution

How to select and edit LabelFields / ButtonFields 2D Array

Hi there everyone, I'm new here and I'm new to blackberry development.

For a student project I'm working on, I have a 2D array of ButtonFields, (which I may change to LabelFields if its easier) which I am using to create a Sudoku grid.

I understand it's really basic but I want to the user to be able to just scroll through the 2D array to a particular cell and be able to type in a number using the keypad to instantly change the label of the ButtonField or LabelField, ie their guess of the Sudoku. 

I'm really having trouble as I'm not familiar with how the blackberry accepts user input and how this can be used with the setText method.

 

So essentially i'd like some sort of way of determining which cell is currently selected (without it being clicked) and then for this currently selected cell to have the setText() method applied to it


Can anybody help me? I can post up code if it helps but I'm not sure it will as you'll al understand how basic it is.

Thank you in advance and I hope I can return the favour soon

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to select and edit LabelFields / ButtonFields 2D Array

you can use a focuschangelistener to be aware of focus changes. or call getLeafFieldWithFocus() to retrieve the current field.

 

you cannot make buttonfields editable, but you can read the user input and process it.

 

for sudoku you need only the numbers, you can use the keyChar method to read entered characters.

check if your focused field is one of your buttons. check if the entered char or alted char (Keypad.getAltedChar)  is a digit (Characters.isDigit).

 

you can call setText on the buttonfield.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
New Contributor
Posts: 5
Registered: ‎04-20-2010
My Device: 8700
My Carrier: o2

Re: How to select and edit LabelFields / ButtonFields 2D Array

thanks a lot for your help, its worked!