如何将参数(用户名和密码)传递给函数signinactivity

时间:2017-04-13 03:11:36

标签: java android login

在这里,我得到了另一个名为signinactivity的类,我想将用户名和密码传递给该特定函数。

但我的代码似乎有问题。有人对代码有所了解吗?

public void loginPost(View view){
    String username = usernameField.getText().toString();
    String password = passwordField.getText().toString();
    new SigninActivity().execute(username, password);
}

1 个答案:

答案 0 :(得分:0)

使用param执行方法。

public SigninActivity(String username,String password) {
        this.username = username;
        this.password = password;
    }

您可以使用构造函数接收方法的参数。

def method(self, vals):
    if not vals.get('field'):
        #if empty use your logic
    else:
        #if not empty use data that was already there.
        #to print field value:
        print vals['field']

            #and if that field is in other model , how can i reach it.
        you may reach it by search that field in other model.