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: 950
Registered: ‎06-22-2010
My Device: 9550

Re: use the values of one screen to nextscreen

When U concat the two String then U should check that the Final String is right Or not

from print that String on console.

Trusted Contributor
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: use the values of one screen to nextscreen

the format which yu all gave is right.

 

but the list items are generated at runtime by parsing

and in my first screen the list contains abt 10 items

and i cant generate 10 screens or 10 .java files it ll make more

complicated.

 

so i want to use something like getselecteditem in the place

                        UiApplication.getUiApplication().pushScreen(new screen2(getselecteditem))ld

which pushes to the screen2 of selecteditem.

whatever listitem i select it shoud take me to screen2 and it should direct to the selected


items link

 

Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: use the values of one screen to nextscreen

hey kirtiga

 

its not necessary to create 10 screens

u need to create only one screen ,

u just have to change the arguments

like:

 

 

String str="";// this will contain data that u need to pass on to the Screen2

if(mylist.getSelectedIndex==2)

 {

   str="link2"; //suppose link2 is the data that u want to pass to next screen

   UiApplication.getUiApplication.pushscreen(new Screen2(str))

}

if(mylist.getSelectedIndex==3)

 {

   str="link3"; //suppose link3 is the data that u want to pass to next screen

   UiApplication.getUiApplication.pushscreen(new Screen2(str))

}

 

 

 

in Screen 2:

 

 

class Screen2 extends MainScreen

 {

    Screen2(String str)

     {

          if(str=="link2")

            //do coding

          if(str=="link3")

           //do coding

     }

 }


 

 

 

its just a matter of passing arguments to 1 screen

just a basic concept

Trusted Contributor
Posts: 204
Registered: ‎07-14-2010
My Device: 8100
My Carrier: Blackberry developer

Re: use the values of one screen to nextscreen

its not vvorking ..

please correct the code if its wrong

 

 

SCREEN 1

class appl extends ...
{
private appl app;




 String str="";

                //for(int i = 0;i <= _list.getSelectedIndex();i++)
                	 if(_list.getSelectedIndex()==0)
                	{
                       	 str= "Home";                                  	 
                		
                   		UiApplication.getUiApplication().pushScreen(new ascreen(str));
                    }
                	 if(_list.getSelectedIndex()==1)
                	 {
                	     str="Sports";
                	     
                	     UiApplication.getUiApplication().pushScreen(new ascreen(str));
                	 }
                		  
                	 }

SCREEN 2
                	 
                

private class Connection extends Thread
	{ 
	    public Connection()
	    { 
	       super(); 
	    } 
	    
	    public void run() {  
	    	Document doc;  
	    	StreamConnection conn = null; 
	    	InputStream is = null;  
	    	
	    	
	    	try {     
	    			  
	    		if(app.str=="Home"){
	    		String u =" http://www.test.com/category?type=cat&name=";
	    		String s = app.str;
	    		String k = ";deviceside=true";
	    		String url = u + s + k ;
	    		 	
	    			    		///+ app.str;deviceside=true ";
	    		conn = (StreamConnection) Connector.open (url); 

 

 

Highlighted
Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: use the values of one screen to nextscreen

[ Edited ]

i think u didnt understand the concept of passing arguments!!!

 u wrote in your first screen:

 

UiApplication.getUiApplication().pushScreen(new ascreen(str));

it means ascreen is a class that extends Mainscreen and u r passing arguments to it

 

u should collect it like:

 

 

class ascreen extends MainScreen
{
ascreen(String str)
{
super();
Connection obj = newConnection(str);
//now here u have passed the string to connection class
}
}

 

 

 

now

private class Connection extends Thread
{
public Connection(String str)
{
super();
}
//now inside run u can do comparison with str
.........
.....
.
.

.
}