BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-14-2007, 07:41 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default creating dynamic EditFields

Please Login to Remove!

hi,
i want to create dynamic EditField for my HorizontalFieldManager.
There are some cases where i need 5 Field and there are cases where i need 20 10 or 7 Fields.

is something like this possible?
Code:
for (int i = 1; i < 11; i++) {
myHorizontalField.add(new EditField "Field"+i("caption",...);
}
so that i have 10 fields at the end named like Field1, Field2, Field3,....

thanks hibbert
__________________
My English is so bad, that makes me nobody so quickly after

Last edited by hibbert : 06-14-2007 at 07:43 AM.
Offline  
Old 06-14-2007, 09:48 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2005
Model: 8830
Carrier: Verizon
Posts: 144
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

hibbert,

I've done something similar with LabelFields. Declare/define an array for your fields.

Private LabelField fields[];

Once you know how many fields you will need, you define the specific size of the array.

fields = new LabelField[tblSz];

Then you just start creating the fields in your array.

fields[fldIndex++] = new LabelField(...);

fbrimm
Offline  
Old 06-14-2007, 10:12 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
ok that sounds good but works not correctly (or i did it the wrong way )
Code:
 hfm.deleteAll();
                             fields = new LabelField[5];
                             
                             for (int i = 0; i < 5; i++) {
                                 fields[i] = new LabelField("Das ist Feld #"+i);
                                 
                             }
                            hfm.add(fields[0]); 
                            hfm.add(fields[1]); 
                            hfm.add(fields[2]);
but all the fields are displayed in on line, it looks like this:
Das ist Feld #1Das ist Feld #2Das ist Feld#3
it would be better if each labelField get it's own row ;)

i also tried
Code:
fields[i] = new LabelField("Das ist Feld #"+i,LabelField.USE_ALL_WIDTH);
but then only the first field is displayed and nothing from the other fields...

hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 06-14-2007, 10:39 AM   #4 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

hfm is a horizontal field manager. you need a vertical field manager if you want your fields in an own row each
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 06-14-2007, 01:12 PM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2005
Model: 8830
Carrier: Verizon
Posts: 144
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Or you can use both horizontal and vertical field managers if you want cells to go across and down (like a spreadsheet). Check out RIM's example on how to create a table. Essentially, you create a HFM, create an array of VFMs that you add to the HFM, and you add the elements of your field array to the VFMs.

fbrimm
Offline  
Old 06-15-2007, 02:45 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks alot =)

now i got what i want and a little bit more ;)

thanks again.
__________________
My English is so bad, that makes me nobody so quickly after
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.