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
zinzinzan
Posts: 90
Registered: ‎04-03-2012
My Device: 9100

Remove Dynamically Fields issue (left )

hi there,

 i have one issue when i tray to update or invalidate Screen, is a simple code with one VerticalFieldManager with a lot of HorizontalFieldsManagers, and that Managers have inside A=bitmapField and lbl = labels with some text, and x = is a buttonfield, well here is the thing this xbutton have a listener that removes entire hfm , but every time i call a invalidate() op updateLayout() "after remove a hfm" ; i get the x field moved a little. pls help i put some code below

 

Before remove a hfm and call invalidate or updateLayput :

------------------------------

|   A   |       lbl         |   x    |          -----> hfm

------------------------------

|    A  |       lbl         |    x   |          ------> hfm

------------------------------

|    A  |       lbl         |    x   |          -------> hfm

------------------------------

|    A  |       lbl         |    x   |          --------> hfm

------------------------------

after remove a hfm and call invalidate or updateLayput :

------------------------------

|   A   |       lbl            |   x    |          -----> hfm

------------------------------

|    A  |       lbl            |    x   |          ------> hfm

------------------------------

|    A  |       lbl            |    x   |          -------> hfm

------------------------------

 

 

_hfm = new HorizontalFieldManager(USE_ALL_WIDTH | Field.FOCUSABLE);
			GridFieldManager gridMgr = new GridFieldManager(1, 2,
					USE_ALL_HEIGHT);
			
			_btnRemove = new CustomImageButton(_bitmapDelete, FIELD_RIGHT | Field.FOCUSABLE);
			setListenerBtnRemove(_btnRemove,_messageVo,_hfm);
			
			gridMgr.add(_lblName);
			gridMgr.add(_btnRemove);
			gridMgr.setColumnProperty(0, GridFieldManager.FIXED_SIZE,
					(Display.getWidth() - 2 * Constants.IMG_SIZE));
			gridMgr.setColumnProperty(1, GridFieldManager.FIXED_SIZE,
					Constants.IMG_SIZE);
			gridMgr.setRowProperty(0, GridFieldManager.PREFERRED_SIZE,
					Constants.IMG_SIZE);

			_hfm.add(_btnIcon);
			
			_hfm.add(gridMgr);
			
			_vfm.add(_hfm);

 help !!!

Developer
zinzinzan
Posts: 90
Registered: ‎04-03-2012
My Device: 9100

Re: Remove Dynamically Fields issue (left )

help? :Whistling:

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Remove Dynamically Fields issue (left )

Invalidate() should not be needed here, and does not change anything in terms of layout anyway - it is just a request for a repaint. 

 

You should not need to updateLayout in this situation, the remove should kick one of these off for you.

 

So try the process without these two and see what happens. 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Remove Dynamically Fields issue (left )

i would consider using a listfield instead of the vfm/hfm construction.
----------------------------------------------------------
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
Developer
Dionysus
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900

Re: Remove Dynamically Fields issue (left )

I agree with simon, create a custom list field instead of the combination of managers.

Developer
zinzinzan
Posts: 90
Registered: ‎04-03-2012
My Device: 9100

Re: Remove Dynamically Fields issue (left )

[ Edited ]

thx for reply well i was taking a look to the list field examples i found a good one on stackoverflow  (  the third answerd )  http://stackoverflow.com/questions/1872160/how-to-customize-a-listfield-in-blackberry i just miss one thign to use this in my app, how i can put fieldChangeListener to the Label and bitmapField insinde the row, that would be great. y try as usully i do with other fields 

  for (int x = 0; x < 10; x++) {
	   TableRowManager row = new TableRowManager();

	   	BitmapField _bitField = new BitmapField(p3);
	    row.add(_bitField);
	   setListener(_bitField);

	   // SET THE TASK NAME LABELFIELD
	   // if overdue, bold/underline
	   LabelField task = new LabelField("Service #" + String.valueOf(x),
	     DrawStyle.ELLIPSIS);
	   task.setChangeListener(new FieldChangeListener() {
		
		public void fieldChanged(Field field, int context) {
			Dialog.alert("preeeee");
			
		}
	});


 private void setListener( BitmapField _bitField ) {
		 
		 _bitField.setChangeListener(new FieldChangeListener() {
			
			public void fieldChanged(Field field, int context) {
				
				Dialog.alert("presed");
				
			}
		});
		
	}

 my coworkers an Android Developer said he do this with a ListViev and set listener for the entire whole row and one listener for the button/Image and the left, and work fine, i wonder if i can achieve this??? 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Remove Dynamically Fields issue (left )

on a listfield you draw the whole row, you don't add fields there. TableRowManager are not a listfield and don't offer the great performance of it.

the listfield design relies on the click on the full row, other actions are offered in the context menu (bb key).
this is the environment bb users are used to, i would suggest to use it.
----------------------------------------------------------
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
Developer
zinzinzan
Posts: 90
Registered: ‎04-03-2012
My Device: 9100

Re: Remove Dynamically Fields issue (left )

well u was rigth i try without invalidate or update layout and repaint again but i still have the issue, i need do it with fields because my boss tell me do it with that looks and fell, press the button and remove, i only need solve this issue  must be easy to fix.

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Remove Dynamically Fields issue (left )

Sorry, being lazy here, can you give us sample code that we can run that demonstrates this?  Please use standard Fields where you can.  Cheers.

Developer
zinzinzan
Posts: 90
Registered: ‎04-03-2012
My Device: 9100

Re: Remove Dynamically Fields issue (left )

heyy ofc i can  :Yes:, i try make the example smaller but without lose the important things, here u can download the project   http://www.ogangi.com/~rsolorzano/mypackage.rar , just make new project delete default class and paste mines, well as i said before when un press the remove button u will se the issue