Blackberry 如何为自定义Choicefield创建弹出窗口并调用它?

Blackberry 如何为自定义Choicefield创建弹出窗口并调用它?,blackberry,custom-controls,Blackberry,Custom Controls,我通过扩展ObjectChoiceField创建了自己的简单ChoiceField。。就像 public class MyChoiceField extends ObjectChoiceField { public MyChoiceField(String label ,Object[] choices) { super(label, choices); } protected void layout(int width, int heig

我通过扩展ObjectChoiceField创建了自己的简单ChoiceField。。就像

public class MyChoiceField extends ObjectChoiceField 
{

    public MyChoiceField(String label ,Object[] choices) 
    {
        super(label, choices);
    }

    protected void layout(int width, int height) 
    {
        setMinimalWidth(width/2-62);
        super.layout(width, height);
    }

    public void paint(Graphics graphics)
    {
        super.paint(graphics);
    }    
}
现在,我想在自定义菜单中选择MyChoiceField时显示我的选择,而不是blackberry在用户单击ChoiceField时提供的默认弹出窗口

我怎样才能做到呢?样本代码将是可观的。。 谢谢

尝试覆盖ObjectChoiceField的方法fieldChangeNotifyint上下文,如下所示:

public class MyChoiceField extends ObjectChoiceField 
{

    public MyChoiceField(String label ,Object[] choices) 
    {
        super(label, choices);
    }

    protected void layout(int width, int height) 
    {
        setMinimalWidth(width/2-62);
        super.layout(width, height);
    }

    protected void fieldChangeNotify(int context) {

        int index = getSelectedIndex();

        try{
            VerticalFieldManager vfm = new VerticalFieldManager();

            vfm.add(new LabelField("[Pop Up Content]\nChoice Field Changed #\n"+choices[index]+" selected."));

            PopupScreen popUpScreen = new PopupScreen(vfm){
                public boolean onClose()
                {
                    this.close();
                    return true;
                }
            };

            UiApplication.getUiApplication().pushScreen(popUpScreen);

        } catch(Exception exc) {
            System.out.println("Exception in choiceField fieldChangeNotify");
        }
    }

    public void paint(Graphics graphics)
    {
        super.paint(graphics);
    }
}
String[] choices; // Keep This Global
VerticalFieldManager vfm = new VerticalFieldManager(Manager.FIELD_VCENTER);            
choices = new String[2];
choices[0] = new String("Choice1");
choices[1] = new String("Choice2");
vfm.add(new MyChoiceField("Choise", choices));
现在使用MyChoiceField的方式如下:

public class MyChoiceField extends ObjectChoiceField 
{

    public MyChoiceField(String label ,Object[] choices) 
    {
        super(label, choices);
    }

    protected void layout(int width, int height) 
    {
        setMinimalWidth(width/2-62);
        super.layout(width, height);
    }

    protected void fieldChangeNotify(int context) {

        int index = getSelectedIndex();

        try{
            VerticalFieldManager vfm = new VerticalFieldManager();

            vfm.add(new LabelField("[Pop Up Content]\nChoice Field Changed #\n"+choices[index]+" selected."));

            PopupScreen popUpScreen = new PopupScreen(vfm){
                public boolean onClose()
                {
                    this.close();
                    return true;
                }
            };

            UiApplication.getUiApplication().pushScreen(popUpScreen);

        } catch(Exception exc) {
            System.out.println("Exception in choiceField fieldChangeNotify");
        }
    }

    public void paint(Graphics graphics)
    {
        super.paint(graphics);
    }
}
String[] choices; // Keep This Global
VerticalFieldManager vfm = new VerticalFieldManager(Manager.FIELD_VCENTER);            
choices = new String[2];
choices[0] = new String("Choice1");
choices[1] = new String("Choice2");
vfm.add(new MyChoiceField("Choise", choices));

让我知道这个解决方案是否有效。

不知道“下拉弹出”是什么意思。。。也许你想说的是选择名单。您说我想创建一个新的“弹出窗口”,我希望我的应用程序在单击Choicefield时显示我自己的弹出窗口。就像当我们选择choicefield作为sex时,我想在弹出窗口中显示选项male和feale。在黑莓手机上可能吗?比如,在www.facebook.com上的生日。我想展示一月/二月/三月。。。我自己设计的。它是possible@sujith,当你解释你的问题时,我觉得答案还可以。但是现在,你想要一个包含你的选择的弹出窗口吗?如果是,那么在黑莓手机中也是可能的。您必须创建自己的弹出窗口并调用doModal。。喜欢这个方法。@Rupak。。我已经试过了。。但实际上我不知道如何实现它。你能指导我如何实现它吗?样本代码将是可观的。。