Can i call dialog box on popup screen in blackberry? - blackberry

In my blackberry application i make one popup screen which is popup on click of menu item. on that popup screen i took one button. Now i want to show alert dialog box on click of that button.How to do this ?Plz tell me.

You can do like this.
public void fieldChanged(Field field, int context)
{
if(field.equals(your button object))
{
Dialog.alert("Your message");
}
}

Related

How to prevent dialog from closing automatically on click in blackberry

I am developing an application in which i create a Dialog with Edit Field and save/Cancel button, i use validation on edit field,i want that if user enter valid entry and click save then the dialog should close but now the problem is when user click on save without enter any text in edit field dialog closes automatically,i want to prevent it after entering valid entry dialog should close.
I give cancel button to discard dialog.
Please help..how to achieve this..........
mOKButton.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field f, int arg1) {
if(_editText.getText()=="")
{
// do nothing
}
else{
_editText.setText(items[getSelectedIndex()]);
close();
}
}
});

Add field manager to application Main screen in BlackBerry

I am working with a BlackBerry application for OS 5.0 and later. The application has one screen which displays at the top of screen a Next and a Previous button. and list field also display in this screen at bottom of these both button
When i click on NEXT Button and Previous Button my List will be updated display data..
When i click on NEXT/PREVIOUS Button i have to display small VerticalfieldManager at the center of the screen with Label "Please wait ..." so after design this screen how can we add more field manager in over the another manager ?
Is there any way to display that Field at the application MainScreen like iPhone AppDelegate screen?
btnState.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context)
{ vfm_Middle.add(lblPleasewait);
popup = new PopupScreen(manager);
Thread thread = new Thread()
{
public void run()
{
try
{
Updatelistfield();
stop();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
super.run();
}
public synchronized void stop()
{
// TODO Auto-generated method stub
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run()
{
// TODO Auto-generated method stub
//popup.delete(vfm_Main);
//popup.deleteAll();
//vfm_Main.delete(lblPleasewait);
//lblPleasewait.setText(null);
}
});
}
};
thread.start();
}
});
The proper way of doing that is with a blocking dialog. In BB API this can be done as follows:
VerticalFieldManager manager = new VerticalFieldManager();
manager.add(new LabelField("Please Wait..."));
Screen popup = new PopupScreen(manager);
//Show the pop-up the same way you push a regular screen
This has the advantage of blocking the GUI: if the user pushes the menu or esc key it doesn't have any effect.
If you want to do it in your screen without dialogs, then you can add an empty VerticalFieldManager which you can fill with a label when the message has to be shown. This way, instead of updating the entire screen, only the Manager is refreshed. But then you should write the logic to not letting the user push any button or menu key (or ignoring key press).

Blackberry popup menu appear on Button click event

I have a problem that popup menu appear when I click a button field. I will solve it by using Buttonfield.consumeclick but it also appears on RichTextField focus. How can I solve this? I am overriding RichTextField method, and that is the reason the popup menu appears.
ButtonField c = new ButtonField("button", FIELD_LEFT | ButtonField.CONSUME_CLICK) {
protected boolean navigationClick(int status, int time) {
Status.show("Button has clicked");
// write your code.
return true;
}
}

Blackberry screen navigation

I want to know how to go from one screen to another by clicking a button that I have added to a MainScreen. I mean just like we do in the Android onClick event for a button - start another startActivity.
In the event handler for the button click, just "push" the screen that you want to appear next, and it will be pushed to the top of the screen stack. For example:
UiApplication.getUiApplication().pushScreen(nextScreen);
This will be better, using FieldChangeListener
button.setChangeListener(new FieldChangeListener()
{
public void fieldChanged(Field field, int context)
{
UiApplication.getUiApplication().pushScreen(new NextScreen());
}
});
This is the alternative way than using,
UiApplication.getUiApplication.involeLater()
{};

hiding menu on click

I am using NullField() in one of my screen so that the default focus should not be on any of the button . but when i am clicking on the screen where no field is there , menu screen is being displayed. i dont want that menu screen to be poped up tough it should open when i click menu button.
Thanks alot
override method.
protected boolean navigationClick(int status, int time) {
Field focus = UiApplication.getUiApplication().getActiveScreen()
.getLeafFieldWithFocus();
if (focus instanceof NullField) {
return true;
}
return super.navigationClick(status, time);
}
Note:This code is only for giving you hint.

Resources