2010-06-30 9 views

Répondre

1

essayer cette

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 beaucoup pour votre aide. Comment puis-je obtenir une sortie? S'il vous plaît..Aidez-moi à..Im nouveau Pour blackberry c'est pourquoi je demande de chaque chose. Merci –

+0

cela signifie que comment puis-je ajouter à mon affichage. Parce que le ticker n'est pas un champ –