开发者

move the BlackBerry focus from code

I have 3 buttons A, B and C. When I click A, the page reloads and the focus will be on A and when I click B, the page reloads and focus will be on B and so on. How do I implement this?

if(constants.focuz.equals("开发者_JAVA技巧next")){ 
          next.setFocus(); 
}else if (constants.focuz.equals("prev")){ 
          prev.setFocus(); 
} else{ 
          abtme.setFocus(); 
}


Your code is Ok. You probably call it on a non-UI thread? If yes, then use UiApplication.invokeLater(Runnable action) to reset the focus. So it should be something like this:

UiApplication.getUiApplication.invokeLater(new Runnable() {
    public void run() {
        if (constants.focuz.equals("next")) {
            next.setFocus();
        } else if (constants.focuz.equals("prev")) {
            prev.setFocus();
        } else {
            abtme.setFocus();
        }
    }
});


To set focus for the button field you have to use

setFocus() method.

Example code:

ButtonField lf=new ButtonField("Button");

lf.setFocus();

Hope this will help you

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜