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 logic of the program

Hey

 

In my application i have a labelfield which is clickable.

When i click on it another screen gets open and after performing some task the current screen  gets closed and i am moved to the same screen having labelfield.

 

But this time i have changed the name of the labelfield and now when i click on the label field another screen gets open.

 

Suppose this is my screen1 having label as Label1

text1 = "Label1"

label1 = new LabelField(text1,LabelField.FOCUSSABLE)

{

protected boolean navigationClick(int status, int time)
{

if(text1.equals("Label1")

{

UiApplication.getUiApplication.pushScreen(new MyScreen1());

}

else if(text1.equals("Label2"))

{

UiApplication.getUiApplicatio.pushScreen(new MyScreen2());

}

   return true;

}

};

 

In MyScreen1 is am changing the name of Labelfield as Label2.

MyScreen1()

{

Screen1.label1.setText("Label2");

}

 

The problem is when i click on Label1, MyScreen1 gets open and it changes the name of the labelField.

But when i click on Label2 again MyScreen1 gets open

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

Re: Problem in logic of the program

You said:

"In MyScreen1 is am changing the name of Labelfield as Label2.

MyScreen1()

{

Screen1.label1.setText("Label2");

}"

 

Then your test:

"if(text1.equals("Label1")"

does not make sense, you need to test the current label, for example:

"if(label1.getText().equals("Label1")"

 

But why bother having screen 1 do this.  You could do this in your originating screen for example:

"if(text1.equals("Label1")

{

text1 = Label2;

label1.setText(text1);

UiApplication.getUiApplication.pushScreen(new MyScreen1());

}"

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

Re: Problem in logic of the program

[ Edited ]

Thanks for the reply.

 

I will try and then let u know.

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

Re: Problem in logic of the program

Thanks Peter

I found the solution.

Please use plain text.