天天看点

黑莓开发第一篇:开发环境的搭建

入手黑莓开发 ,第一步肯定是搭建环境了,黑莓提供了自己的JDE开发工具,但是个人以为十分之不方便,还是选择eclipse插件比较好,黑莓官网的服务器在加拿大 ,访问速度慢如蜗牛,这里我给迅雷下载地址:

http://bbsdk.csdn.net/BlackBerry_JDE_PluginFull_1.1.2.201004161203-16.exe

下载之后,按照默认安装即可

安装好了之后 ,按照开发习惯,先写一个helloWorld小例子,打开eclipse,点击File-new,选择project,然后选择blackberry project ,工程名HelloWorld,建好之后就可以编辑代码了

public class MyApp extends UiApplication {

/**

* Entry point for application

*

* @param args

* Command line arguments (not used)

*/

public static void main(String[] args) {

// Create a new instance of the application and make the currently

// running thread the application's event dispatch thread.

MyApp theApp = new MyApp();

theApp.enterEventDispatcher();

}

/**

* Creates a new MyApp object

*/

public MyApp() {

// Push a screen onto the UI stack for rendering.

pushScreen(new HelloWorldScreen());

//new MenuCanvas();

}

}

final class HelloWorldScreen extends MainScreen {

public HelloWorldScreen(){

super();

LabelField title = new LabelField("HelloWorld", LabelField.ELLIPSIS);

setTitle(title);

add(new ButtonField("Submit"));

}

public boolean onClose() {

//Status.show("Hello World!");

Dialog.ask(Dialog.D_OK_CANCEL, "are you sure?", Dialog.NO);

System.exit(0);

return true;

}

 这样直接在虚拟机运行就ok啦!

继续阅读