hello_world.he
来自「维信SDK文档。源码要求为至少5个C或Java源码」· HE 代码 · 共 67 行
HE
67 行
class hello_world{ //It's nice to store command ids to static constants const int CMD_BACK = 1; //MenuItems are displayed over phone's soft buttons //Usually to go back, ok, open options menu etc MenuItem BACK = new MenuItem(CMD_BACK, "Back"); //WidSets framework will call createElement() per //each script-element it finds from views being //created by createView() Component createElement(String viewName, String elementName, Style style, Object context) { //return simple label with style defined in widget.xml //in this case "text" if (elementName.equals("hello")) { //in order to get the label align in the middle of the //view you'd need to contain it inside a Flow which //you'd return here return new Label(style, "Hello World"); } return null; } void startWidget() { //instantiate minimized view in startup setMinimizedView(createView("viewMini", getStyle("bg"))); } Shell openWidget() { //instantiate maximized view when user opens this widget Flow view = createView("viewMaxi", getStyle("bg")); return new Shell(view); } MenuItem getSoftKey(Shell shell, Component focused, int key) { //return the key we want to display at position=SOFTKEY_BACK //this usually is the Right Soft Button (RSB), for other key //positions return null, as we don't want other keys if (key == SOFTKEY_BACK) { return BACK; } return null; } void actionPerformed(Shell shell, Component source, int action) { //when CMD_BACK event comes in, pop the current shell (this widget) if (action == CMD_BACK) { popShell(shell); } } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?