Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Contributor
smcbride15
Posts: 8
Registered: 07-07-2010
My Carrier: None
Accepted Solution

Dialog with only a cancel button

[ Edited ]

Hi, I'm trying to create a dialog with only a cancel button. I've extended the dialog class to do this in the constructor:

 

 

public SessionDialog(String title){

 

super(dialogResponse, title, dialogResponse, null, dialogResponse);

 

Manager manageLayout = new HorizontalFieldManager( VERTICAL_SCROLLBAR);

 

ButtonField b =new ButtonField("Cancel",Field.FIELD_HCENTER);

 

manageLayout.add(b);

add(manageLayout);

 

 

}

 

And call it like this:

 

SessionDialog d =new SessionDialog( "Please Wait, creating session");

d.show();

 

However I still get a dialog with ok and cancel buttons, how do I just get the cancel button to show?

 

Thanks

Please use plain text.
Developer
simon_hain
Posts: 10,780
Registered: 07-29-2008
My Carrier: O2 Germany

Re: Dialog with only a cancel button

i would suggest to use a standard popupscreen. dialog is a specialized popupscreen, if you need something out of its scope its better to do it yourself

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

peter_strange wrote:
"This process should happen traumatically for you in both JDE and Eclipse."
Please use plain text.
New Contributor
smcbride15
Posts: 8
Registered: 07-07-2010
My Carrier: None

Re: Dialog with only a cancel button

Can you give me an example of a PopUpScreen with only a cancel button and how to show it? I have a custom update method in my Dialog class which I'm rather keen to retain so I'd really like to solve this by keeping my Dialog class if at all possible

 

Thanks

Please use plain text.
Developer
peter_strange
Posts: 14,611
Registered: 07-14-2008

Re: Dialog with only a cancel button

Please use plain text.
Developer
rrey2279
Posts: 44
Registered: 06-16-2009

Re: Dialog with only a cancel button

Dialog with Cancel button only:

 

 

UiEngine ui = Ui.getUiEngine();

Dialog cancelPrompt = new Dialog("Loading...", new String[] { "Cancel" }, new int[] { Dialog.CANCEL }, Dialog.CANCEL, Bitmap.getPredefinedBitmap(0));

ui.pushGlobalScreen(cancelPrompt, 1, UiEngine.GLOBAL_MODAL);



// use cancelPrompt.close() to close the Dialog automatically from another thread or method

 

 

Please use plain text.
New Contributor
smcbride15
Posts: 8
Registered: 07-07-2010
My Carrier: None

Re: Dialog with only a cancel button

Ok thanks for the replies, RE the last response, how do I add a listener to that Dialog for the cancel button. Also how do I pop that Dialog from a background thread?

 

many thanks

Please use plain text.
New Contributor
smcbride15
Posts: 8
Registered: 07-07-2010
My Carrier: None

Re: Dialog with only a cancel button

Figured both out. Listener can be created during the Dialog creation like so:

 

 

Dialog cancelPrompt = new Dialog("Loading...", new String[] { "Cancel" }, new int[] { Dialog.CANCEL }, Dialog.CANCEL, Bitmap.getPredefinedBitmap(0)){
public void fieldChanged(Field field, int context)
 {
System.out.println("something happened!");
 }
};

 

 

 

Thanks for your replies guys

Please use plain text.