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
Posts: 329
Registered: ‎12-17-2010
My Device: Not Specified
My Carrier: developer

How to get data from screen2 to screen1 ?

Hi ,

 

In my application , There are two screens : screen1 contains a label and button with text 'colorpicker' . and screen2 contains set of radio buttons like green , blue , red, white. When ever i select one button i have this color vale to screen and i need to update a label with color ?

 

Can any one help me how to transfer data between screns ?

 

Regartds,

Satish

Highlighted
New Developer
Posts: 17
Registered: ‎11-19-2009
My Device: Not Specified

Re: How to get data from screen2 to screen1 ?

Use Fieldmanager properly also use replace(Field newField,Field oldfield);

Developer
Posts: 237
Registered: ‎05-07-2010
My Device: 8520
My Carrier: Internet

Re: How to get data from screen2 to screen1 ?

 

hi,

you can change the label color by the below code.

 

public class screen1 extends mainscreen implements fieldcangedlistner
{
public Labelfield l1;
public Buttonfield b1;
public int color=Color.RED;
      public void screen1()
      {

               LabelField objLabel = new LabelField("test test")
               { 
                   public void paint(Graphics g){ g.setColor(Color.RED); super.paint(g); } };

            b1=new Buttonfield("button");

           //add label and button to screen

             
      }
public void fieldChanged(Field field,int context)
{
      //push the screen2 from  here
  
        
     
}


}

 

now from your  second screen do the below.

public class screen2 extends mainscreen
{
   screen1 obj1=null;

   public screen2(   screen1 obj1)
  {
      this.screen1=screen1;
     //add your option button here or in else method that u  want

  }
 //implemet option button events


}

 

 

now on option button events just  change the value of color.

like screen1.color=color.blue

 

and push the screen with invaokelater.and invalidate the screen.

 

and for screen you can use paint method.

 

 

thankx

 

 

 

 

 

 

 

 

 

 

 

___________________________________________________
please press kudos(star button on left) if this post is helpful to you
"Accept as solution" if your query has been resolved.@hitendra
_________________________________________________
Developer
Posts: 329
Registered: ‎12-17-2010
My Device: Not Specified
My Carrier: developer

Re: How to get data from screen2 to screen1 ?

Hi what is the meaning of push screen  with invoke later ?

Regular Contributor
Posts: 55
Registered: ‎08-26-2010
My Device: 8520

Re: How to get data from screen2 to screen1 ?

 

UiApplication app = UiApplication.getUiApplication();
		app.invokeLater(new Runnable() {

			public void run() {
				app.pushScreen(screen);
			}

		});