首先确定Form上添加Item还是addCommand(Command c)。
1.如果是前者,在这个Form上实现一个ItemCommandListener接口,然后做一个select按钮,再对每个Item调用setDefaultCommand(select)和setItemCommandListener(this);最后在实现接口时自动跳出来的itemCommandAction(Command command, Item item)函数内,根据item来决定跳转的界面。跳转通过Display类的setCurrent(Displayable d)来实现。
2.如果是后者,首先要实现一个CommandListener接口,然后用addCommand(Command c)添加按钮。再在commandAction(Command command, Displayable d)里,根据command来决定应该setCurrent到哪个界面
1.如果是前者,在这个Form上实现一个ItemCommandListener接口,然后做一个select按钮,再对每个Item调用setDefaultCommand(select)和setItemCommandListener(this);最后在实现接口时自动跳出来的itemCommandAction(Command command, Item item)函数内,根据item来决定跳转的界面。跳转通过Display类的setCurrent(Displayable d)来实现。
2.如果是后者,首先要实现一个CommandListener接口,然后用addCommand(Command c)添加按钮。再在commandAction(Command command, Displayable d)里,根据command来决定应该setCurrent到哪个界面
本文介绍了在Midlet中如何实现界面跳转的两种方法:一种是通过在Form上添加Item并实现ItemCommandListener接口;另一种是使用addCommand并实现CommandListener接口。详细解释了如何设置默认命令和监听器,并在相应的接口方法中根据命令或Item来决定跳转的目标界面。
8274

被折叠的 条评论
为什么被折叠?



