 |
MOTO手机开发的问题汇总
日期:2004-4-26 0:01:18 作者:rocks 文档类型:原创 来自:蓝色理想数码站 |
|
|
6怎么在主类中响应按钮消息,这个对于切换显示很有帮助。
//文件名 LWTDemoMIDlet.java import com.motorola.lwt.*; import javax.microedition.lcdui.*; import javax.microedition.midlet.*;
public class LWTDemoMIDlet extends MIDlet implements CommandListener { class ButtonScreen extends ComponentScreen {
public ButtonScreen() {
// Add a button to the screen Button b1 = new Button("b"); ///////////下面的代码是设定按钮高度 b1.setBottomEdge(Component.HEIGHT, 30);
///////////下面的代码是设定按钮宽度 b1.setRightEdge(Component.WIDTH,80);
///////////下面的代码是设定按钮y坐标,a相对屏幕最上
b1.setTopEdge(Component.SCREEN_TOP, 10);
///////////下面的代码是设定按钮x坐标相对前一个控件 b1.setLeftEdge(Component.PREVIOUS_COMPONENT_RIGHT, 30);
add(b1);
// Add another button to the screen Button b2 = new Button("点我就行了"){ public void componentActuated() { Show(); } }; // Extend the right edge to the right edge of the screen b2.setRightEdge(Component.WIDTH, 220); b2.setBottomEdge(Component.HEIGHT, b2.getPreferredHeight() * 2); add(b2); Command next = new Command("Next", Command.OK, 1); Command prev = new Command("Previous", Command.BACK, 1);
addCommand(next); addCommand(prev); } };
ButtonScreen screens = new ButtonScreen(); public LWTDemoMIDlet() { screens.setCommandListener(this); } protected void startApp() throws MIDletStateChangeException { Display.getDisplay(this).setCurrent(screens); } protected void pauseApp() { } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { } public void Show() { System.out.println("Get it on main Class");
} public void commandAction (Command c, Displayable d) {
if (screens == d) { // Found it, check which command was triggered if (c.getCommandType() == Command.BACK) { System.out.println("back"); } else if (c.getCommandType() == Command.OK) { System.out.println("ok"); } return; }
}
}
|
| 蓝色理想数码站版权申明:除部分特别声明不要转载,或者授权我站独家播发的文章外,大家可以自由转载我站点的原创文章,但原作者和来自我站的链接必须保留(非我站原创的,按照原来自一节,自行链接)。文章版权归我站和作者共有。
转载要求:转载之图片、文件,链接请不要盗链到本站,且不准打上各自站点的水印,亦不能抹去我站点水印。
特别注意:本站所提供的摄影照片,相关评测,如需使用,请与原作者联系,版权归原作者所有
|
|
 |
· 谈音质标准与音质评价方法
· MP3维修知识经验总结
· 数码相机简易自制立体影像
· 数码照片拍摄用光经验谈
· 手机游戏下载完全实用攻略
· SP智能手机使用IA资源管理器快捷键汇总
· 了解智能手机的操作系统们
· 手机游戏下载完全实用攻略 · SP智能手机使用IA资源管理器快捷键汇总 · 了解智能手机的操作系统们 · 免费WAP风起云涌 移动未来谁主? · [香港] 结束等待!索爱Z800i行货正式开卖 · 小心你的手机也中毒! · 手机常见九大故障自我排除法 · 16个手机相关名词释疑 · 主流无线传输技术GPRS与CDMA对比 · GPRS服务详细介绍
|