BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-20-2010, 08:05 AM   #1 (permalink)
New Member
 
Join Date: Apr 2010
Model: 8700
PIN: N/A
Carrier: o2
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default How to select and edit LabelFields / ButtonFields 2D Array

Please Login to Remove!

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

Last edited by easyp : 04-20-2010 at 08:56 AM.
Offline  
Old 04-20-2010, 03:05 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

You should take a look at GridFieldManager here:

components - Thinking BlackBerry
Offline  
Old 04-21-2010, 12:08 AM   #3 (permalink)
New Member
 
Join Date: Nov 2009
Location: Bangalore
Model: 8900
OS: v4.6.1.31
PIN: 2573CBD3
Carrier: Airtel
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

In your MainScreen class override the method keyUp(int arg0, int rg1)and inside it you can call the method getFieldWithFocus(); and set the text.
Offline  
Old 04-21-2010, 07:25 AM   #4 (permalink)
New Member
 
Join Date: Apr 2010
Model: 8700
PIN: N/A
Carrier: o2
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
You should take a look at GridFieldManager here:
I'm already using gridfieldmanager to create the grid, but thanks for your suggestion

Quote:
Originally Posted by vinitthakur View Post
In your MainScreen class override the method keyUp(int arg0, int rg1)and inside it you can call the method getFieldWithFocus(); and set the text.
Thanks for your help, I'm doing something along those lines now
Offline  
Old 04-21-2010, 07:28 AM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

OK, then what is your question exactly?
Offline  
Old 04-21-2010, 07:37 AM   #6 (permalink)
New Member
 
Join Date: Apr 2010
Model: 8700
PIN: N/A
Carrier: o2
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
OK, then what is your question exactly?
Quote:
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
Sorry if I didn't make myself clear, there was a lot of preamble to my actual question hehe

maybe you could help me with my other problem? I can't post the link up but its in the same forum. Thanks for your help

Last edited by easyp : 04-21-2010 at 07:39 AM.
Offline  
Old 04-21-2010, 10:11 AM   #7 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Your manager should tell you which field has the focus, right?

Field field = Manager.getFieldWithFocus()

Or, if you have nested managers, you may need to call

Field field = Manager.getLeafWithFocus()
Offline  
Old 04-22-2010, 08:33 AM   #8 (permalink)
New Member
 
Join Date: Apr 2010
Model: 8700
PIN: N/A
Carrier: o2
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks a lot that worked for me
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.