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
New Developer
Posts: 47
Registered: ‎04-16-2009
My Device: Not Specified
Accepted Solution

multiple screen

Hi friends,

 

 i am new guy to blackberry. In the main screen i am displaying a set of button as add, delete, subtract button in the bottom of the screen.By default add button is selected and the middle portion of the screen contains some button specific to add.when user clicks on the delete button i wanted to show user another screen with button in the middle of the screen associated to the delete operation.so how can i display different screen on button click.

   plz guide me with some sample code so that i can proceed further.

 

thanks&regards

preeti 

 

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: multiple screen

You have to use pushScreen method to put the other screen on disply.

 

If you are new to BB development, I would suggest you to go thru this thread.

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=13264


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: multiple screen

When the button is clicked, you push the new screen. You can determine the button was clicked by attaching a FieldChangeListener to the button.

 

You should take a look at some of the sample code that ships with the JDE. There are several examples of what you are trying to do.

 

Highlighted
Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: multiple screen

Hi,

 

Plz. go thru this code, 

 

---------------------------------------------------

 

import net.rim.device.api.ui.*;

class Main extends UiApplication{
   
   
    Main() {
       
            first fr = new first();
            pushScreen(fr);
       
            }

public static void main(String [] args){
   
   
    Main ref = new Main();
    ref.enterEventDispatcher();
   
    }


----------------------------------------------------------------------

 


import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.Screen.*;
import net.rim.device.api.ui.container.*;



public class first extends MainScreen implements FieldChangeListener{
    
    private EditField edit1,edit2;
    private LabelField lbl1,lbl2;
    private ButtonField b1,b2;
     
    first() {
        
    this.setTitle("First");
    
    edit1 = new EditField(EditField.USE_ALL_WIDTH|EditField.READONLY|EditField.NO_NEWLINE);
    edit2 = new EditField(EditField.USE_ALL_WIDTH|EditField.READONLY|EditField.NO_NEWLINE);
    lbl1 = new LabelField("Enter First Name :");
    lbl2 = new LabelField("Enter Last Name :");
    b1 = new ButtonField("second");
    b2 = new ButtonField("Next");
    
    
    this.add(lbl1);this.add(edit1);
    this.add(lbl2);this.add(edit2);
    this.add(b1);
    b1.setChangeListener(this);
    this.add(b2);
    b2.setChangeListener(this);
    
            }

public void fieldChanged(Field field, int context){
    
    
    if(field instanceof ButtonField)
    {
        
        String lbl = ((ButtonField)field).getLabel();
        
        if(lbl.equals("second")){
            
            second sc = new second();
            UiApplication.getUiApplication().pushScreen(sc);
            
            }
            
            else if(lbl.equals("Next")){
                
                Dialog.alert("Next is under Construction...!!");
                
                }
     
     }
    
    
    }


}
------------------------------------------------------

 

It will give you a fine idea of using multiple screens.

 

Kanak SonySmiley Happy

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
New Developer
Posts: 47
Registered: ‎04-16-2009
My Device: Not Specified

Re: multiple screen

Hi Kanaksony,

 

 

  How should my secondscreen class look like

 

thanks&regards

Developer
Posts: 232
Registered: ‎12-15-2008
My Device: 9700
My Carrier: Vodafone India

Re: multiple screen

You can designed it in the same way u did for class first.

 

u can use same code for  class "sc" which u r calling in class first button option which is (UiApplication.getUiApplication().pushScreen(sc)Smiley Wink

 

U can change the field name and can add more option as required

 

Thnx

New Developer
Posts: 47
Registered: ‎04-16-2009
My Device: Not Specified

Re: multiple screen

hi,

  

 when i am  using the function below

 

public void fieldChanged(Field field, int context)
    {
        resscreen = new RestoreScreen();
        UiApplication.getUiApplication().pushScreen(resScreen);
 
    }

 

i am gettin the following error

 

 UiApplication.getUiApplication().pushScreen(resScreen);

 

plz give me some solution

 

Thanks&Regards

New Developer
Posts: 47
Registered: ‎04-16-2009
My Device: Not Specified

Re: multiple screen

hi,

  

 when i am  using the function below

 

public void fieldChanged(Field field, int context)
    {
        resscreen = new RestoreScreen();
        UiApplication.getUiApplication().pushScreen(resScreen);
 
    }

 

i am gettin the following error

 

 C:\RIM\First_App\HelloWorld\src\HelloWorld.java:181: cannot find symbol
symbol  : variable resScreen
location: class HelloWorld.HelloWorldScreen
        UiApplication.getUiApplication().pushScreen(resScreen);

 

plz give me some solution

 

Thanks&Regards

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: multiple screen

Please check the Spelling.

UiApplication.getUiApplication().pushScreen(resScreen) -> UiApplication.getUiApplication().pushScreen(resscreen);


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 232
Registered: ‎12-15-2008
My Device: 9700
My Carrier: Vodafone India

Re: multiple screen

Did u defined "resScreen" class