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

Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel
Accepted Solution

Getting the text from Edit Field

[ Edited ]



In my Application, i am adding a check box, a label field and a Edit Field in a Grid Field manager. Then this grid Field manager, i am adding multiple times in Vertical Field manager. So it is looking like List of items. Now when i checked five check box, i am trying to get the text of the correspondent edit field.


This is the code for Grid Field Manager:

int c[] = {screenWidth/6, (screenWidth)/3, (screenWidth)/2};
		gm = new GridFieldManager(c, Manager.VERTICAL_SCROLL);
		Logger.out("Grocery", "Here it is coming"+i);
		cbfChecked = new CustomCheckBoxField();
		cbfChecked.setChangeListener(new FieldChangeListener() 
			public void fieldChanged(Field field, int context) 
				if(checked[i] == false)
					checked[i] = true;
				else if(checked[i] ==  true)
					checked[i] = false;
					Logger.out("Grocery", "It is UnChecked" +checked[i]);
		Logger.out("Grocery", "Adding first Label Field");
		LabelFieldCustom lfFrom = new LabelFieldCustom((String) m_vtrItems.elementAt(i),Color.BROWN,FONT_FAMILY_0_SF_AS_16,Field.FIELD_LEFT);
		Logger.out("Grocery", "Adding second Label Field");
		efcAmount = new EditFieldCustom(Bitmap.getBitmapResource("dob_text_box.png"), 25);
		efcAmount.setMargin(new XYEdges(30, 0, 0, 0));
		return gm;

 Here i am adding the grid field manager multiple times:


for (int i = 0;i < m_vtrItems.size();i++)

			vfm.add(new SeparatorField(SeparatorField.NON_FOCUSABLE));


Here is the snap shot of my screen:9800.png 


Please help me.

Posts: 16,652
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Getting the text from Edit Field

you could access the field by index (prone to errors though).
or you could save your fields in a data structure, like a hashtable, with the checkboxfield as key, the editfield as value.
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
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel

Re: Getting the text from Edit Field

Yes. i take the edit fields in an array and they accessing their indexes when i am selecting the check boxes.