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
eraman
Posts: 34
Registered: ‎03-08-2012
My Device: Simulator
Accepted Solution

Hiding fields in blackberry

hi, i want to hide some fields such as:-TextField,ButtonField,labelfield etc...on buton click.

For example: button1 and button2 are present in base class and after pressing button1 the control moves to next screeen where there are fields such as textfield & button ields which i want to hide and similarly when button2 is pressed the other fields should be visible and only few buttons should be hidden....

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

Re: Hiding fields in blackberry

use delete or add to hide or show fields.
----------------------------------------------------------
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
eraman
Posts: 34
Registered: ‎03-08-2012
My Device: Simulator

Re: Hiding fields in blackberry

i have tried it already...................not working
i have tried these already..........
---------------------------------------------------------------------------------
---((TextField)name).getManager().delete(datetimefield);
---((ButtonField)selectfromMap).selectionDelete();
---selectfromMap.setEditable(false);
----------------------------------------------------------------------------------
these donot work at all....is there any other method??????
Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Hiding fields in blackberry

"not working" is a not a very good problem description.
usually you get an illegalstateexception when you try something wrong, and the detail message states clearly what is wrong, for example "field not child of this manager".
----------------------------------------------------------
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
eraman
Posts: 34
Registered: ‎03-08-2012
My Device: Simulator

Re: Hiding fields in blackberry

By "Not working" i mean that those fields are shown instead of deleting them...........no error at all in the code......
do u have any other solution to this problem?????
Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Hiding fields in blackberry

if you delete the correct reference the field will no longer be shown. i use this mechanism in a lot of cases and never had any problems.
----------------------------------------------------------
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
eraman
Posts: 34
Registered: ‎03-08-2012
My Device: Simulator

Re: Hiding fields in blackberry

let me give u an example.......
____________Class1___________
btn1 btn2
_____________________________

_____________class2__________

btn3----
textfield------

labelfield
btn4
---------------------------------------------------------

now when i click btn1....it will show btn3 & textfield
and when btn2 is pressed it will show label and btn4

hence i need to "-----HIDE----" two fields every time.
Now when i write the above techniques the all for fields are still shown together......this is the problem..........
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Hiding fields in blackberry

[ Edited ]

"I have tried these already..........
---------------------------------------------------------------------------------
---((TextField)name).getManager().delete(datetimefield);
---((ButtonField)selectfromMap).selectionDelete();
---selectfromMap.setEditable(false);
----------------------------------------------------------------------------------"

 

1) ((TextField)name).getManager().delete(datetimefield);

If you want to delete datetimefield, then the correct code would be:

datetimefield.getManager().delete(datetimefield);

 

2) (ButtonField)selectfromMap).selectionDelete();

SelectionDelete is intended to be used for Text Field where the user has selected a section of the Text.  As the documentation says:

"By default, this method does nothing; custom fields that support deletion operations must override this method"

ButtonField does not implement this.  By contrast, ActiveAutoTextEditField does.

 

3) selectfromMap.setEditable(false);

The documentation says:
"This method lets you change the style of this field by either adding, or removing, the Field.EDITABLE style."

So you can make the Field not editable, and it will look and behave differently, but not remove it.

 

In summary, the delete is the only option that will work, I suggest the reason it did not work for you was that you were not selecting the Field's manager correctly.

 

Edit:

 

I have not seen your latest post when I added the above.

 

In this case I suggest that you create a Manager that is added in the correct position, that, by default, does not contain any Fields.  When the appropriate Button is clicked, add the Fields you want to that Manager.  When the Fields should be deleted, use the Manager deleteAll() method to remove all the Fields you do not want to display.  That should work for you. 

Developer
eraman
Posts: 34
Registered: ‎03-08-2012
My Device: Simulator

Re: Hiding fields in blackberry

the code successfully worked .............thanks  Simon_hain and Peter Strange

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

Re: Hiding fields in blackberry

please mark the thread as solved, then.
----------------------------------------------------------
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