BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-23-2008, 12:12 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2008
Model: 8800
PIN: N/A
Carrier: Orange
Posts: 26
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Asking for a string

Please Login to Remove!

Hey everyone.
I want to implement a class that is a popup screen that just prompts a String question and receives a String response.
but I'm getting tangled.


can someone give me some sample uses of Popup Screen
preferably, like what i asked.
Offline  
Old 04-24-2008, 01:40 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Develop ur own custom class which extends PopupScreen class property.

1.add RichTextField for question string.

2.add TextField for response string.

3.Receive the text typed in the TextField.

4.U have done with that.
Offline  
Old 04-24-2008, 02:47 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2008
Model: 8800
PIN: N/A
Carrier: Orange
Posts: 26
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

can you please give me a code sample?
on a main screen is would look something like this.

class CAskForString extends MainScreen
{
static private String _result;
private EditField _edit;
static String AskForString(String sTitle, String sQuestion, String sInitValue)
{
UiApplication.getUiApplication().pushModalScreen(
new CAskForString(sTitle, sQuestion, sInitValue));
return _result;
}

CAskForString(String sTitle, String sQuestion, String sInitValue)
{
_result = null;
LabelField title = new LabelField(sTitle, LabelField.ELLIPSIS
| LabelField.USE_ALL_WIDTH);

setTitle(title);

_edit = new EditField(sQuestion, sInitValue);
add(_edit);
}

public void save()
{
_result = _edit.getText();
}
}

how do i change it to pop up screen?
if i extend popup screen i need to give it a manager.
it always comes out weird,
can you help me with changing it?
thanks.
Offline  
Old 04-24-2008, 05:26 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Before u want to do such stuff, i wud request u to study API specification once.

Plan what r u goin to do according to what u need.
Offline  
Old 04-24-2008, 06:30 AM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2008
Model: 8800
PIN: N/A
Carrier: Orange
Posts: 26
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, well, i did read API.
but its true that i dont fully understand the manager/screen stuff too much.
thats why i asked for help here.

can you at least point me out to some reading material. (i still think that sample code would be the quickest for me to understand)
thanks,
Omri
Offline  
Old 04-24-2008, 06:38 AM   #6 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

There is a good article from Mark Sohm. It might help you to understand BB's GUI.

BlackBerry Graphical User Interface Part 1

Also look for the examples provided with JDE

Last edited by Ivanov : 04-24-2008 at 06:39 AM.
Offline  
Old 04-24-2008, 10:03 AM   #7 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2008
Model: 8800
PIN: N/A
Carrier: Orange
Posts: 26
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK,
i read it.
but i still dont understand how to properly use the popup screen.
i created the popup screen.
but how do i add a menu to it?

and how do i make it so that it behaves like a main screen in the fact that when trying to click return and one of the manager fields are dirty it displays the save/discard dialog?

thanks. Omri

Last edited by omrib : 04-24-2008 at 10:08 AM.
Offline  
Old 04-25-2008, 01:24 AM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
public class CustomField extends UiApplication {

    public CustomField() {
    pushScreen(new CAskForString("sample popup","Place Question here?",""));
       
    }
    
    public static void main(String args[]) {
        CustomField main = new CustomField();
        main.enterEventDispatcher();
    }
Code:
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiEngine;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.FlowFieldManager;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.Graphics;
/**
 * 
 */
public class CAskForString extends MainScreen {
    static private String _result;
      
    public CAskForString(String sTitle, String sQuestion, String sInitValue) {
        LabelField title = new LabelField(sTitle, LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);
        AskForString(sTitle,sQuestion,sInitValue);
      }
    
    static String AskForString(String sTitle, String sQuestion, String sInitValue) {
        UiEngine ui = Ui.getUiEngine();
        ui.pushGlobalScreen(new Popscreen(sQuestion), 1, true);    
        return _result;
    }
    
    public void save() {
    }
}

final class Popscreen extends PopupScreen {
    
    public Popscreen(String question) {
        super(new FlowFieldManager());
        add(new RichTextField(question, NON_FOCUSABLE));
        add(new EditField("Answer: ",""));
        
    }
    
    public void paint(Graphics graphics) {        
        graphics.clear();
        super.paint(graphics);
    }
    
    public boolean onClose() {
        System.exit(0);
        return true;
    }   
}
Try the above code. import whatever class necessary if i missed.

This is just a simple thing i have done. U can do a lot with this basics.

All de best.
Regards,
Hithayath.
Offline  
Old 04-25-2008, 01:32 AM   #9 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2008
Model: 8800
PIN: N/A
Carrier: Orange
Posts: 26
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks alot!
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.