0
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");
    }
}

我想newMethod通过单击 ButtonField 来调用方法。checkPlay我在课堂上放了一个 ButtonField 。单击该 ButtonField 应调用newMethod. 但是这段代码不起作用。

需要帮忙。

4

1 回答 1

3

尝试这样的事情:

ButtonField playButton = new ButtonField("Test Button"){
     protected boolean navigationClick(int status, int time){
          signUp sinup=new signUp();
          sinup.newMethod();
          return true;
     }
};
于 2012-08-06T09:15:53.433 回答