shappy1978 发表于 2013-1-29 07:28:46

Kuix安装指导

    看到有人询问Kuix安装,而且运行Demo出现问题,其实在用过的几个UI包中,Kuix算是安装最简单的了,基本上只要包括Kuix和Kutil两个jar包就可以,这两个包在http://www.kalmeo.org/projects/kuix/download可以下载,其中Kutil提供基础类库,比如Textarea中的xml解析器就在这个包中,同时建议下载源代码,因为要做比较强大应用的话,这个包还是有不少问题的,不是bug,而是功能较弱,以后我会专门出一篇介绍Kuix的不足之处和改善方法.安装步骤如下:
    下载最新的WTK,并安装,配置(具体搜索相关的文章),注意网上部分开源J2ME的包对于低版本的WTK是不能运行的,目前我用的是2.5.2.
    引入Kuix,Kutil包,并做下图的配置.记得不要把J2ME的包删掉,Kuix还是基于J2Me的包的,虽然不用直接继承J2ME的任何基类.
http://dl.iteye.com/upload/attachment/164398/28ffdecb-53f4-32f5-83c6-ba9383fe3f3e.jpg
    新建Midlet suit,接着不用新建Midlet了,而是继承KuixMIDlet,然后依照指南建立Frame和XML
midlet代码,需要加载fram和css样式,直接复制KuixDemo的样式和图片即可.

public class Helloworld extends KuixMIDlet {public Helloworld() {// TODO Auto-generated constructor stub}public void initDesktopContent(Desktop arg0) {Kuix.getFrameHandler().pushFrame(new HelloworldFrame());}public void initDesktopStyles() {Kuix.loadCss("style.css");}} frame代码,这是我演示动态数据绑定的demo:

public class HelloworldFrame implements Frame {public void onAdded() {// TODO Auto-generated method stubScreen screen = Kuix.loadScreen("hello.xml", null);    screen.setCurrent();}public boolean onMessage(Object identifier, Object[] arguments) {// TODO Auto-generated method stub    if ("about".equals(identifier)) {      Kuix.alert(Kuix.getMessage("CREDITS"), KuixConstants.ALERT_OK);      return false;    }    if ("exitConfirm".equals(identifier)) {      // display a popup message      Kuix.alert(Kuix.getMessage("EXIT_CONFIRM"), KuixConstants.ALERT_YES | KuixConstants.ALERT_NO, "exit", null);      return false;    }    if ("exit".equals(identifier)) {      // get the midlet instance to invoke the Destroy() method      Helloworld.getDefault().destroyImpl();      //if the event has been processed, we return 'false' to avoid event forwarding to other frames      return false;    }      if ("showDynamic".equals(identifier)) {      Kuix.getFrameHandler().pushFrame(new Dynamic());      return false;    }      if ("showCombo".equals(identifier)) {      Kuix.getFrameHandler().pushFrame(new combo());      return false;    }    // return "true" makes the FramHandler to forward the message to the next frame in the stack   return true;}public void onRemoved() {// TODO Auto-generated method stub}} hello.xml

<?xml version="1.0" encoding="UTF-8"?><screen shortcuts="1=about|back=exitConfirm|0=exitConfirm"><_title>%HELLOWORLD%</_title>    <container style="layout:inlinelayout(false,fill); align:center">      <text><_text>%HELLOWORLD%</_text></text>      <picture src="logo.png" />      <button onAction="showDynamic">%DYNAMIC_DISPLAY%</button>      <button onAction="showCombo">combo dynamic</button>      <button onAction="about">%ABOUT%</button><button onAction="exitConfirm">%EXIT%</button>    </container>    <screenFirstMenu onAction="exit">Exit</screenFirstMenu><screenSecondmenu>    %MORE%    <menuPopup>      <menuItem onAction="about" shortcuts="1">            %ABOUT%      </menuItem>      <menuItem onAction="exitConfirm" shortcuts="back|0">            %EXIT%      </menuItem>    </menuPopup></screenSecondmenu>   </screen> 这样就可以运行了.另外如果需要修改代码的话建立添加source link,选择项目,右键,properties,java build path,source标签,点link source按钮,添加Kuix和Kutil源码的目录,这样就可以多个项目共享Kuix的源码,又可以方便的直接修改源码.
http://dl.iteye.com/upload/attachment/164404/4d0d6f43-b1f0-359a-9351-b68419c14243.jpg
页: [1]
查看完整版本: Kuix安装指导