08-17-2012 04:09 PM - edited 08-17-2012 04:12 PM
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?
Solved! Go to Solution.
08-17-2012 07:42 PM
show and hide are usually achieved by adding (show) or removing (hide) compoents. Does that work for you?
08-18-2012 04:30 PM
08-19-2012 08:42 PM - edited 08-19-2012 08:48 PM
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...

08-19-2012 08:54 PM
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.
08-19-2012 09:09 PM - edited 08-19-2012 09:18 PM
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 ![]()
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..
08-19-2012 09:44 PM - edited 08-19-2012 09:45 PM
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.createSolidBa ckground(Color.WHITE));
}
}
}
08-20-2012 10:58 AM
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
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.
08-20-2012 12:50 PM - edited 08-20-2012 12:53 PM
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!