Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java me LWUIT进度条_Java Me_Progress Bar_Lwuit_Gauge - Fatal编程技术网

Java me LWUIT进度条

Java me LWUIT进度条,java-me,progress-bar,lwuit,gauge,Java Me,Progress Bar,Lwuit,Gauge,我想在开始时显示一个进度条,指示正在加载应用程序 如何做到这一点?我已经创建了一个量表,但我认为它不能以LWUIT形式实现。根据我的评论,您可以使用进度条。您还可以使用,而不是在LWUIT中显示进度条。最好的方法是使用画布。您可以在所有应用程序中重用该类,而且非常高效。创建一个类,比如一个名为Splash的类: public class Splash extends Canvas { private final int height; private final int width; priv

我想在开始时显示一个进度条,指示正在加载应用程序


如何做到这一点?我已经创建了一个量表,但我认为它不能以LWUIT形式实现。

根据我的评论,您可以使用进度条。您还可以使用,而不是在LWUIT中显示进度条。

最好的方法是使用画布。您可以在所有应用程序中重用该类,而且非常高效。创建一个类,比如一个名为Splash的类:

public class Splash extends Canvas {

private final int height;
private final int width;
private int current = 0;
private final int factor;
private final Timer timer = new Timer();
Image AppLogo;
MayApp MIDlet;

/**
 *
 * @param mainMIDlet
 */
public Splash(MyApp mainMIDlet) {

    this.MIDlet = mainMIDlet;
    setFullScreenMode(true);
    height = getHeight();
    width = this.getWidth();
    factor = width / 110;
    repaint();
    timer.schedule(new draw(), 1000, 01);
}

/**
 *
 * @param g
 */
protected void paint(Graphics g) {
    try {//if you want to show your app logo on the splash screen
        AppLogo = javax.microedition.lcdui.Image.createImage("/appLogo.png");
    } catch (IOException io) {
    }
    g.drawImage(AppLogo, getWidth() / 2, getHeight() / 2, javax.microedition.lcdui.Graphics.VCENTER | javax.microedition.lcdui.Graphics.HCENTER);
    g.setColor(255, 255, 255);
    g.setColor(128, 128, 0);//the color for the loading bar
    g.fillRect(30, (height / 2) + 100, current, 6);//the thickness of the loading bar, make it thicker by changing 6 to a higher number and vice versa
}

private class draw extends TimerTask {

    public void run() {
        current = current + factor;
        if (current > width - 60) {
            timer.cancel();
            try {
                //go back to your midlet or do something
            } catch (IOException ex) {
            }
        } else {
            repaint();
        }
        Runtime.getRuntime().gc();//cleanup after yourself
    }
}
}

在你的腹部:

public class MyApp extends MIDlet {

Splash splashScreen = new Splash(this);

    public MyApp(){
}

public void startApp(){

    try{
        Display.init(this);
        javax.microedition.lcdui.Display.getDisplay(this).setCurrent(splashScreen);
        //and some more stuff
        } catch (IOException ex){}
}
//continue

看看现有的讨论