开发者

How to determine the type of object in blackberry application?

On my screen i have ButtonField and CustomButtonField. Both have been added to Listner of my screen.

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

Now i want to know which button is clicked and type of object in fieldChanged function.

public void fieldChanged(Field field, int context) {

//Here- how to determine the type o开发者_JAVA百科f object //which object has been clicked //ButtonField or CustomButtonField???? }

Kindly Help Thanks SIA


instanceof is your friend:

public void fieldChange(Field field, int context) {
    if(field instanceof CustomButtonField)
       ;//do something
    else if(field instanceof ButtonField)
       ;//do something
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜