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
}
精彩评论