05-21-2012 02:22 AM
Hi all,
I admit, I have posted this question already and gave a lot of code examples on StackOverflow here:
But I also read peter strange's article here:
Both didn't help. Since I really need help with this, I hope you forgive me the crossposting. I promise to provide the solution on both platforms as soon as I have one.
In short, what I'm trying to do is having a YES/NO dialog on startup of the app. The startup procress should be stopped, until the user clicks yes or no. If he clicks yes a method should be called and after the method has been completely processed, startup should continue.
Thanks a lot.
Dinakel
Solved! Go to Solution.
05-21-2012 02:31 AM
You should push a global screen with the MODAL option.
This should give you what you need:
E.
05-21-2012 02:47 AM
05-21-2012 03:35 AM
Thanks a lot Simon and Maadani!
Here is the SSCCE that finally does what I want it to do. I also tried without the test.invokeLater() in the main-method. That doesn't work. Probably this is obvious for you, but I still have some trouble understanding the threading model of BB apps.
I haven't tried with pushModalScreen, mainly because I need a Listener then. This makes the interaction asynchron and I would need another wait/notfiy construct or similar to make the main thread stop and continue, when the Listener gets notified. Am I wrong?
Thanks anyway, I will start implementing it in my actual application now and hopefully it works there as well.
SSCCE:
package TestDialog;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;
public class TestDialog extends UiApplication implements Runnable
{
/**
* @param args
*/
public static void main(final String[] args)
{
final TestDialog test = new TestDialog();
test.invokeLater(test);
test.enterEventDispatcher();
}
public TestDialog()
{
}
public void run()
{
final int answer = Dialog.ask(Dialog.D_YES_NO, "continue?");
// pushGlobalScreen(new Dialog(Dialog.D_YES_NO, "continue?", 0, null, Dialog.GLOBAL_STATUS), 1, TestDialog.GLOBAL_QUEUE | TestDialog.GLOBAL_MODAL);
if (answer == Dialog.YES)
{
System.out.println("user clicked yes");
}
else
{
System.exit(0);
}
pushScreen(new MyScreen("App loaded"));
}
class MyScreen extends MainScreen
{
public MyScreen(final String msg)
{
final LabelField title = new LabelField("First Screen", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
this.add(new RichTextField(msg));
}
}
}
05-21-2012 03:45 AM