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
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer
Accepted Solution

Problem in the logic of code.

Hi

I wan to make  a button ,when i click on it a paragraph gets open and when i click again on the button the paragraph gets dissapear.

Like this i have 10 buttons. I have to make this paragraph label as dynamic.

 

How to do this??

Please use plain text.
Developer
simon_hain
Posts: 16,023
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Problem in the logic of code.

depends on what the paragraph actually is.
if it is a textfield, richtextfield or the like you can just remove it from the screen.
if it is a more complex construct wrap it into a container and remove the container.

you can re-add the field/container on another click.
one possibility to detect if the field is currently added would be to call field.getManager and check it for null (= not added).
----------------------------------------------------------
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
Please use plain text.
Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in the logic of code.

Hey

Thanks for the reply.

 

 

I am adding a manager. But the problem is if i have 3 buttons and i click on button1 then its manager gets added after button 3.

I want the manager gets added just below the button.

Please use plain text.
Developer
simon_hain
Posts: 16,023
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Problem in the logic of code.

you can use insert to add a field/manager on a certain position
----------------------------------------------------------
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
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in the logic of code.

Another approach, to save having to remember where everything should be added, is to create and add a empty Manager for each place where you might add a page. 

 

For example, say you create ManagerPage1, ManagerPage2, ManagerPage3 and so on immediately after their Button.  Then add to this when the page is added, delete everything from it when it removed.  So you would add the text to ManagerPage3 when the 3rd page's button is pressed. 

Please use plain text.
Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in the logic of code.

Hey Thanks Simon

 

The problem is solved!!!.

Please use plain text.
Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in the logic of code.

Hey 

I am getting one error.

 

If i have 3 buttons:

i have inserted  text1 at 1, text2 at 3 and text3 at 5.

 

When without clicking on button1 or button2 , i directly click on button 3 , then the exception occur.It can't add the field at 5.

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

Re: Problem in the logic of code.

We need to know more that you have given us to resolve this problem.  And since you have marked this as solved, start a new question. 

 

But rather than hard code these insert indexes, try my solution. 

Please use plain text.
Developer
simon_hain
Posts: 16,023
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Problem in the logic of code.

the indexes would have to be calculated, if you have inserted manager 1 the position for manager2 would be different.

i would also suggest that you try peters suggestion, it may be easier to use and understand for you.
----------------------------------------------------------
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
Please use plain text.
Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in the logic of code.

Hey Thanks Simon and Peter.

The problem is solved!!!!

Please use plain text.