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
New Developer
vishalkheterpal
Posts: 134
Registered: ‎01-11-2011
My Device: curve

ListField problem

Hi

 

I am creating a list field.

listfield = new ListField(len) {

protected void layout(int width, int height) {
super.layout(width, height);

setExtent(currentWidth - ConstantsUI.LIST_WIDTH,
len * 72); // len is the no. of items in list.
}

 

 

and adding this listfield on 

mainVodManager = new VerticalFieldManager(VERTICAL_SCROLL) {
			protected void paintBackground(Graphics graphics) {
				graphics.setBackgroundColor(0x000000);
				graphics.clear();
				super.paint(graphics);
			}

			protected void sublayout(int maxWidth, int maxHeight) {
				super.sublayout(maxWidth, maxHeight);
				if (ConstantsUI.ScreenState == "land") {
					setExtent(
							currentWidth - ConstantsUI.LIST_WIDTH - 5,
							ConstantsUI.CHANNEL_HEIGHT
									+ ConstantsUI.NAME_HEIGHT + 10);

				} else {
					if (currentWidth == 360 && currentHeight == 480) {

						setExtent(currentWidth - ConstantsUI.LIST_WIDTH
								- 5, ConstantsUI.CHANNEL_HEIGHT
								+ ConstantsUI.EPG_HEIGHT
								+ ConstantsUI.APP_ICON_HEIGHT + 10);
					} else
						setExtent(currentWidth - ConstantsUI.LIST_WIDTH
								- 5, ConstantsUI.HEIGHT
								+ ConstantsUI.EPG_HEIGHT
								+ ConstantsUI.APP_ICON_HEIGHT + 10);
				}
			}
		};

 

It is working fine.But when i rotate my device.Now the scrolling is not working fine.Even list get disappears.On sublayout of screen i am calling deleteall and then call the  code to create list again.But it didnot work as expected.

 

 

 

 

 

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

Re: ListField problem

Check your code and I suspect you will find that you get an Exception, probably something like "layout called while layout in progress".

 

You can not do things that will alter the laying out, like remove Fields, in a layout method (which includes sublayout.

 

Instead of doing this, use an invokeLater and do the delete in the invokeLater.  That will itself force a re-layout of the Manager, so you go through sublayout twice.