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
Contributor
EricTheRed03
Posts: 32
Registered: ‎08-13-2012
My Device: 9800
My Carrier: Rogers
Accepted Solution

UI Guidance

[ Edited ]

Hi, on a screen I would like the ability to show/ hide components. As you can see below I have the Modify Option checked so I show the fields associated with this.

 

-------- my main screen layout -----

Confirm [   ]

Modifiy  [X]

        ObjectChoiceField2

        Button2

Delete  [    ]

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

 

Right now my options (Confirm[], Modify[], Delete[]) are just checkbox's. When an event gets fired on the option box I add() the field to the form. But how do I hide/remove the items from the form when the option is unchecked? 

 

What/How you recommend I use to accomplish such a feat?

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: UI Guidance

show and hide are usually achieved by adding (show) or removing (hide) compoents.  Does that work for you? 

Please use plain text.
Developer
anditsung
Posts: 243
Registered: ‎09-30-2010
My Device: Z10, Onyx2
My Carrier: IND XL

Re: UI Guidance

create a manager for the form and listener for option box
if option box get checked add the field to the manager
if not delete all field from manager so it will only display empty manager
Please use plain text.
Contributor
EricTheRed03
Posts: 32
Registered: ‎08-13-2012
My Device: 9800
My Carrier: Rogers

Re: UI Guidance

[ Edited ]

I decided to put each one of the Options (Confirm, Change Owner and Change Status) in a VerticalFieldManager. When the user clicks the checkbox to enable changing owners, I run a method showChangeOwner() which creates all the buttons and adds them to the VerticalFieldManager. When a user deselects one I do a deleteALL() and then just add my Change Owner checkbox back to the manager.

 

The problem is that I have a (START) button at the end Iwhich doesn't seem to show up properly once showChangeOwner() and HideChangeOwner() methods are called. So is adding and removing these components to my Field manager causing a problem? Do I have to tell me mainscreen to recalculate and paint the mainscreen again?

 

It looks like a problem with the Verticle Scrolling on the Mainscreen but I do indeed call

 

    super(MainScreen.VERTICAL_SCROLL | MainScreen.VERTICAL_SCROLLBAR);

 

Any idea why my mainscreen may not be allowing me to scroll to the button?

 

Notice the missing button below...

 

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: UI Guidance

Are you adding the VFM, then adding the Start button?

 

I would try this wit NO style modifiers on the VFM or the MainScreen. 

 

So for the MainScreen, just have

super();

 

and define your VFM just using

new VerticalFieldManager();

 

See if that works OK. 

Please use plain text.
Contributor
EricTheRed03
Posts: 32
Registered: ‎08-13-2012
My Device: 9800
My Carrier: Rogers

Re: UI Guidance

[ Edited ]

It doesn't make the matter any better..and strangely enough each time I select/uncheck the option box the problem gets worse. until I restart the app. And by "the problem getting worse" I mean that at first you can sroll down ot the button fine then I can sroll with half the button showing. Then finally I can't scroll at all.... this doesn't make any sense to me :smileysad:

 

nothing looks off with this I hope..

 

public void showOwner()
{
_ownerFieldManager.add(new SeparatorField());
_ownerName = new EditField("Owner Name: ", "");
_ownerFieldManager.add(_ownerName);
}

public void hideOwner(){
try{
_ownerFieldManager.deleteAll();
_ownerFieldManager.add(_ownerCheckbox);
}
catch (Exception e)
{}
}

 

 

EDIT... On a side thought here.. is it possible that my mainscreen has to re-calibrate the vertical scroll if my components change sizes? This is a total guess..

Please use plain text.
Contributor
EricTheRed03
Posts: 32
Registered: ‎08-13-2012
My Device: 9800
My Carrier: Rogers

Re: UI Guidance

[ Edited ]

I took your advice about "no style modifiers" and I narrowed it down to 1 line..when I comment the line below I am fine.. any idea why?? That lines adds all the prettiness to my app.. so I rather not part ways with its beauty..

 

public class TTVerticalFieldManager extends VerticalFieldManager {
		
	//create static variable for manager type
	final public static String _manTypeBody = "BODY"; 
		
	public TTVerticalFieldManager (String managerType)
	{
		super();
		if (managerType.equals("BODY"))
		{
			Bitmap borderBitmap = Bitmap.getBitmapResource("rounded-border.png");
	        //this.setBorder(BorderFactory.createBitmapBorder(new XYEdges(12,12,12,12), borderBitmap));
	        this.setPadding(2,2,2,2);
	        this.setMargin(3, 3, 3, 3);
	        this.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
		}
	}
}

 

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: UI Guidance


EricTheRed03 wrote:

It doesn't make the matter any better..and strangely enough each time I select/uncheck the option box the problem gets worse. until I restart the app. And by "the problem getting worse" I mean that at first you can sroll down ot the button fine then I can sroll with half the button showing. Then finally I can't scroll at all.... this doesn't make any sense to me :smileysad:

 

EDIT... On a side thought here.. is it possible that my mainscreen has to re-calibrate the vertical scroll if my components change sizes? This is a total guess..


Do you use any custom components? Fields that change their size dynamically? If you do, make sure you invoke their updateLayout() every time their on-screen size should change.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Contributor
EricTheRed03
Posts: 32
Registered: ‎08-13-2012
My Device: 9800
My Carrier: Rogers

Re: UI Guidance

[ Edited ]

Thank you!

You are right in that I found a method called 'updateLayout()' on the VerticalFieldManager. BUT when I added this method on my VerticalFieldManager during resize didn't help.

 

The great news is that I found this method on the mainscreen manager instead! This is working like a charm. Thank you so much!!

 

So to summarize for people..

 

If you customize your VerticalFieldManager with

 

this.setBorder(BorderFactory.createBitmapBorder()

 Then be sure to update your form layout() after deleting or adding components to your VerticalFieldManager.

  

Thanks everyone!

 

 

Please use plain text.