当前位置: 代码迷 >> J2ME >> lwuit 菜单有关问题
  详细解决方案

lwuit 菜单有关问题

热度:923   发布时间:2016-04-17 21:39:38
lwuit 菜单问题
最近刚接触LWUIT 有个问题想问下 普通的菜单怎么设置呢 最好有个例子!谢谢大家

------解决方案--------------------
http://blog.csdn.net/pjw100/archive/2010/01/12/5181903.aspx
这里面应该有你想要的
------解决方案--------------------
简单的例子
Java code
package test;import com.sun.lwuit.Button;import com.sun.lwuit.Command;import com.sun.lwuit.CommandList;import com.sun.lwuit.Component;import com.sun.lwuit.Container;import com.sun.lwuit.Display;import com.sun.lwuit.Form;import com.sun.lwuit.Image;import com.sun.lwuit.Label;import com.sun.lwuit.ProgressBar;import com.sun.lwuit.TextArea;import com.sun.lwuit.events.ActionEvent;import com.sun.lwuit.events.ActionListener;import com.sun.lwuit.layouts.BoxLayout;import com.sun.lwuit.layouts.GridLayout;import com.yooye.uu.DefaultProgress;import java.io.IOException;import javax.microedition.midlet.*;/** * @author Administrator */public class TestMidlet extends MIDlet implements ActionListener {    private Form f;    public void startApp() {        Display.init(this);        f = new Form("Test Form");        //为Form添加菜单========        Command cc = new Command("测试菜单1");        f.addCommand(cc);        f.addCommand(new Command("测试菜单2"));        f.addCommandListener(this);        //为Form添加菜单结束=====        Container con = new Container(new BoxLayout(BoxLayout.Y_AXIS));        f.addComponent(con);        Container con1 = new Container(new BoxLayout(BoxLayout.X_AXIS));        con.addComponent(con1);        con1.addComponent(new Label("姓名:"));        con1.addComponent(new Label("Ckenny.Liu"));        con1.addComponent(new Button("修改"));        Container con2 = new Container(new BoxLayout(BoxLayout.X_AXIS));        con.addComponent(con2);        con2.addComponent(new Label("生日:"));        con2.addComponent(new Label("1985-04-15"));        con2.addComponent(new Button("修改"));        Container con7 = new Container(new BoxLayout(BoxLayout.X_AXIS));        con.addComponent(con7);        con7.addComponent(new Label("电话:"));        con7.addComponent(new Label("13751878888"));        con7.addComponent(new Button("修改"));        f.setScrollableY(true);        f.show();    }    public void pauseApp() {    }    public void destroyApp(boolean unconditional) {    }    public void actionPerformed(ActionEvent evt) {        Object o = evt.getSource();        if (o instanceof Command) {            //菜单事件处理        }    }}
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!