簡體   English   中英

在BlackBerry屏幕上顯示單詞順序

[英]Display sequence of words on BlackBerry screen

我在一個字符串數組中有十個單詞。 例如:{“ AB”,“ CD”,“ EF”,“ GH” ......}。 我必須連續顯示這些單詞,將每個單詞在屏幕上保持2秒鍾。 顯示每個新單詞時,字體大小也需要變小。

如何在BlackBerry上執行此操作?

您可以使用Timer來控制計時:

import java.util.Timer

int index;
String[] words;

...

TimerTask task = new TimerTask() {
    public void run()
    {
         // TODO: Check the bounds and kill the timer when we're done.

         // Invoke the code in the UI Thread
         UiApplication.getUiApplication().invokeLater(new Runnable() {
             public void run()
             {
                // Code to enumerate and concat the string...
             }
          });
     }
 };

timer timer = new Timer();
timer.scheduleAtFixedRate(task, 0, 2000);

更改字體大小:

// in the class body:
final int minFontSize = 5;
int maxFontSize = minFontSize + words.length();

// in the timer's run method:
net.rim.device.api.ui.Font defaultFont = this.getFont();
net.rim.device.api.ui.Font myFont = defaultFont.derive(0, maxFontSize - index)

// change the font of the ui control
field.setFont(myFont);

我沒有檢查代碼是否可以編譯,但是希望您能理解。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM