2011-08-04 6 views
0

처음에 응용 프로그램로드 중임을 나타내는 진행률 표시 줄을 표시하려고합니다.LWUIT 진행률 표시 줄

어떻게 할 수 있습니까? 계기를 만들었지 만 LWUIT 형식으로 구현할 수 없다고 생각합니다.

+2

기존의 논의에서 봐 안부 (HTTP를 : // co.kr /questions/6692881/showing-wait-screen-using-lwuit-in-j2me) – bharath

답변

1

내 의견에 따라 진행률 표시 줄을 사용할 수 있습니다. 또한 LWUIT에서 진행률 표시 줄 대신에 slider component을 사용할 수 있습니다.

0

가장 좋은 방법은 캔버스를 사용하는 것입니다. 모든 앱에서 클래스를 재사용 할 수 있으며 매우 효율적입니다.

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