开发者

How to determine the type of object in blackberry application?

开发者 https://www.devze.com 2022-12-23 16:21 出处:网络
On my screen i have ButtonField and CustomButtonField. Both have been added to Listner of my screen. myScreen.add(new ButtonField(\"click me\"));

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

精彩评论

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

关注公众号