【问题标题】:How to determine the type of object in blackberry application?如何确定黑莓应用程序中的对象类型?
【发布时间】:2010-03-16 14:34:37
【问题描述】:

在我的屏幕上,我有 ButtonField 和 CustomButtonField。 两者都已添加到我屏幕的 Listner 中。

myScreen.add(new ButtonField("点击我")); myScreen.add(new CustomButtonField("click me Again"));

现在我想知道在 fieldChanged 函数中单击了哪个按钮以及对象的类型。

public void fieldChanged(Field field, int context) {

//这里-如何判断对象的类型 //点击了哪个对象 //ButtonField 还是 CustomButtonField???? }

请帮助 谢谢 新航

【问题讨论】:

    标签: blackberry-jde custom-application


    【解决方案1】:
    instanceof is your friend:
    
    public void fieldChange(Field field, int context) {
        if(field instanceof CustomButtonField)
           ;//do something
        else if(field instanceof ButtonField)
           ;//do something
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多