class checkPlay extends MainScreen {
FieldChangeListener listener;
public checkPlay() {
setTitle("Testing");
listener = new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
ButtonField playButton= (ButtonField) field;
signUp sinup=new signUp();
sinup.newMethod();
}
};
ButtonField playButton = new ButtonField("Test Button");
playButton.setChangeListener(listener);
add(playButton);
}
// TODO Auto-generated constructor stub
}
class signUp extends MainScreen {
public signUp(){
// setTitle("Sign Up For New Account");
BasicEditField firstName = new BasicEditField("First Name*: ", "");
BasicEditField lastName = new BasicEditField("Last Name*: ", "");
EmailAddressEditField Email = new EmailAddressEditField("Email*: ", "");
ButtonField joinButton = new ButtonField("JOIN NOW",ButtonField.FIELD_LEFT);
add(firstName);
add(lastName);
add(Email);
add(joinButton);
}
void newMethod() {
setTitle("Dhoni");
}
}
我想通过点击ButtonField来调用newMethod
方法。我在一个checkPlay
课程中放了一个ButtonField。单击该ButtonField应调用newMethod
。但是这段代码不起作用。
需要帮助。
答案 0 :(得分:3)
尝试这样的事情:
ButtonField playButton = new ButtonField("Test Button"){
protected boolean navigationClick(int status, int time){
signUp sinup=new signUp();
sinup.newMethod();
return true;
}
};