ObjectChoicefield在黑莓 [英] ObjectChoicefield in blackberry

查看:410
本文介绍了ObjectChoicefield在黑莓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个选择,因为说YES和NO一个objectchoice场。
我想,当用户选择的选项中的任何一个来处理事件。

I have a objectchoice field with choices as say YES and NO. I want to handle event when the user selects any one of the choices.

例如,当用户选择是的,我想添加到屏幕的labelField。
并没有选择时,这个标签应该从屏幕上消失。

for example when the user selects YES i want a labelField to be added to the screen. and when No is selected this label should be removed from the screen

请帮忙

推荐答案

在你的窗口类,实现FieldChangeLIstener。

In your window class, implement FieldChangeLIstener.

objectChoiceField.setChangeListener(this)

我建议做标记,你要添加的索引/移除标签,这样,在fieldChanged事件中,你可以更容易地做你想做的,而不使用无效的指数风险:

I would recommend doing marking the index of where you want to add/remove the label, so that in fieldChanged event you can more easily do what you want without risk of using an invalid index:

if (selectedIndex == 0) { // Yes
    if (!labelField.hasManager()) { 
        // If the field is not already present, add it to the screen. 
        insert(labelField, positionToInsertField); 
    } 
} else {  // No
    if (labelField.hasManager()) { 
        // Our field is currently on the screen - let's remove it now. 
        remove(labelField); 
    } 
}

您可以在下面的code非常类似行为的一个例子:

You can find an example of very similar behavior in the code below:

http://svn.bbssh.org/trunk/BBSSH/src/org/bbssh/screens/ConnectionPropertiesScreen.java

查找功能handleFontTypeChange,从fieldChangeListener调用。在那里,你将看到如何基于当前的选择(在这种情况下,TrueType字体VS位图字体),我们要添加和删除动态控制。

Look for function "handleFontTypeChange", invoked from fieldChangeListener. In there, you'll see how based on the current selection (in this case truetype font vs bitmap font) we're adding and remove a control dynamically.

这篇关于ObjectChoicefield在黑莓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆