2010-06-30 2 views

답변

1

여러분의 도움이

import java.util.Timer; 
import java.util.TimerTask; 

import net.rim.device.api.system.Display; 
import net.rim.device.api.ui.Field; 
import net.rim.device.api.ui.Font; 
import net.rim.device.api.ui.Graphics; 

public class Ticker extends Field { 

    String text; 
    final int screenWidth = Display.getWidth(); 
    int offset = screenWidth; 
    Timer timer = new Timer(); 
    final int delay = 30; 

    public void setText(String text) { 
     this.text = text; 
    } 

    public String getText() { 
     return text; 
    } 

    Ticker(String text) { 
     this.text = text; 
     final int width = Font.getDefault().getAdvance(text); 
     TimerTask timerTask = new TimerTask() { 
      public void run() { 
       offset--; 
       if (offset + width == 0) { 
        offset = screenWidth; 
       } 
       invalidate(); 
      } 
     }; 
     timer.scheduleAtFixedRate(timerTask, delay, delay); 
    } 

    protected void layout(int width, int height) { 
     int w = Display.getWidth(); 
     int h = Font.getDefault().getHeight(); 
     setExtent(w, h); 

    } 

    protected void paint(Graphics graphics) { 
     graphics.drawText(text, offset, 0); 
    } 


} 
+0

Hay..Thankz을 많이 시도 감사드립니다. 어떻게 출력을 얻을 수 있습니까? 제발 .. 도와 줘. 새로운 것. 블랙 베리에. 그래서 나는 모든 것을 묻는다. –

+0

고맙습니다. 내 디스플레이에 추가 할 수있는 방법을 의미합니다. 티커는 필드가 아닙니다. –