import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Gauge;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
//Gauge组件测试
public class Gauge_test extends MIDlet implements CommandListener {
private Display display;
private Alert al;
public Gauge_test(){
display = Display.getDisplay(this);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
al = new Alert("信息发送中");
al.setType(AlertType.INFO);
al.setTimeout(Alert.FOREVER);
Gauge g = new Gauge(null,false,10,0);
al.setIndicator(g);
Command start = new Command("开始",Command.OK,1);
Command stop = new Command("停止",Command.STOP,1);
al.addCommand(start);
al.addCommand(stop);
al.setCommandListener(this);
display.setCurrent(al);
}
public void commandAction(Command c, Displayable d) {
// TODO Auto-generated method stub
String cmd = c.getLabel();
if(cmd.equals("开始")){
AlertThread t = new AlertThread(al);
al.setString("正在发送信息...");
t.start();
}else if(cmd.equals("停止")){
notifyDestroyed();
}
}
}
//编写一个类
class AlertThread extends Thread{
Alert al;
public AlertThread(Alert al){
this.al = al;
}
public void run(){
Gauge indicator = al.getIndicator();
for(int i= 0;i<11;i++){
indicator.setValue(i);
try{
Thread.sleep(500);
}catch(Exception ex){
ex.printStackTrace();
}
}
}
}
分享到:
相关推荐
NULL 博文链接:https://sunzone.iteye.com/blog/1843925
j2me 的基础文章,很基础,还不错,值得一看。
J2ME应用软件测试指南.pdf
J2ME项目测试文档,J2ME项目测试文档,非常实用
j2me手机游戏开发中免不了测试手机支持的各种参数。本midlet测试精心编写了一系列参数的测试。
J2me音频测试工具
试题本身在开发过程中没有什么太大的意义,只是给初学者特供一个j2me基础知识掌握情况的参考。
自己做的一个j2me下载测试软件,用于连续下载测试用,耗流量软件
NULL 博文链接:https://janla.iteye.com/blog/267857
j2me里面各种漂亮进度条的制作方法,例子和简洁哦~~
奥睿星J2ME测试题奥睿星J2ME测试题奥睿星J2ME测试题
J2ME开发 J2ME开发 J2ME开发 J2ME开发
j2me程序打包出jar过大时,可以用该模拟器运行,可以调模拟器的分辨率,超级好用
这是Form对Item布局的一个演示,仅在于指出如何进行组件居中布局。
J2ME API J2ME API J2ME API J2ME API J2ME API
这是一个测试包,解码库的源代码是由...鉴于目前二维码如此火热,在此发布这个测试器,将其装到支持摄像头的j2me手机上,基本上就能看看效果。应为其原有的测试程序,似乎不能跑。
j2me版手机缘分测试程序源码,输入男女双方名字测算出缘分值 eclipse+eclipseME+WTK开发
基于J2ME的啤酒知识小测试,特别适合初学者
是一本关于J2ME游戏开发方面,做测试方面的一本书
j2me入门教程j2me入门教程j2me入门教程j2me入门教程j2me入门教程