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

Reply
Developer
Posts: 90
Registered: ‎04-03-2012
My Device: 9100
My Carrier: movilnet

add/remove buttons dynamically from gridFieldManager

[ Edited ]

before&laterHi there, i am trying to erase one button and add 2 new ones, in griedfieldManager but when i add tow new buttons, all fields inside the manager get moved to the right and that is the problems here is the code:

 

private void setChangeListener_btnSuscribe() {

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

			final CustomImageButton _btnAddAux = (CustomImageButton) _listBtnAdd
					.elementAt(i);
			final GridFieldManager gridMgrAux = (GridFieldManager) _listGridMngr.elementAt(i);
			final CustomImageButton _btnFreeAux = (CustomImageButton) _listBtnFreeze
					.elementAt(i);
			final CustomImageButton _btnStopAux = (CustomImageButton) _listBtnStop
					.elementAt(i);
		//	final HorizontalFieldManager _hfmAux = (HorizontalFieldManager)_listHfmForGrid.elementAt(i);
			
			_btnAddAux.setChangeListener(new FieldChangeListener() {

				public void fieldChanged(Field field, int context) {
					gridMgrAux.deleteAll();
					//TODO sobreescribiendo la referencia quei esta el detalle,  ahy que modifiarla
					// o obenter el lugar donde esta contenida esta referencia para crear una nueva,
					gridMgrAux.add(new LabelField("name alert.."));
					gridMgrAux.add(_btnStopAux);
					gridMgrAux.add(_btnFreeAux);				

					gridMgrAux.setColumnProperty(0, GridFieldManager.FIXED_SIZE,
							(Display.getWidth() - (3 * Constants.IMG_SIZE) +5 ));

					gridMgrAux.setColumnProperty(1, GridFieldManager.FIXED_SIZE,
							Constants.IMG_SIZE);

					gridMgrAux.setColumnProperty(2, GridFieldManager.FIXED_SIZE,
							Constants.IMG_SIZE);

					gridMgrAux.setRowProperty(0, GridFieldManager.PREFERRED_SIZE,
							Constants.IMG_SIZE);
					gridMgrAux.invalidate();
					
				}
			});

		}
		// new RemoteApi().addLoyappty(serviceVo, _userId);

	}

 

Developer
Posts: 246
Registered: ‎09-30-2010
My Device: Z10, Onyx2
My Carrier: IND XL

Re: add/remove buttons dynamically from gridFieldManager

did you set the new size for gridmanager?
Developer
Posts: 90
Registered: ‎04-03-2012
My Device: 9100
My Carrier: movilnet

Re: add/remove buttons dynamically from gridFieldManager

nop i just make GirdmaganerInstance.deleletAll(); and then insert the new fields

Developer
Posts: 246
Registered: ‎09-30-2010
My Device: Z10, Onyx2
My Carrier: IND XL

Re: add/remove buttons dynamically from gridFieldManager

i think you should set the new size
exp:
the grid only has 2 place to insert field.
if you delete 1 field and insert another 2 field it will become 3 field but the grid only has 2 field...
maybe because of that.

and your image above dont show. i can see how you make it
Highlighted
Developer
Posts: 90
Registered: ‎04-03-2012
My Device: 9100
My Carrier: movilnet

Re: add/remove buttons dynamically from gridFieldManager

nop is alread have 3 slots, check the code 

gridMgr = new GridFieldManager(1, 3, 0);
		_listGridMngr.addElement(gridMgr);
		_hfmAlert = new HorizontalFieldManager(USE_ALL_WIDTH);
		_listHfmForGrid.addElement(_hfmAlert);
		gridMgr.add(_lblName);
		gridMgr.setColumnProperty(0, GridFieldManager.FIXED_SIZE,
				(Display.getWidth() - 3 * Constants.IMG_SIZE));

		gridMgr.setColumnProperty(1, GridFieldManager.FIXED_SIZE,
				Constants.IMG_SIZE);

		gridMgr.setColumnProperty(2, GridFieldManager.FIXED_SIZE,
				Constants.IMG_SIZE);

		gridMgr.setRowProperty(0, GridFieldManager.PREFERRED_SIZE,
				Constants.IMG_SIZE);