Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在单击按钮时验证方法_Java_Android - Fatal编程技术网

Java 如何在单击按钮时验证方法

Java 如何在单击按钮时验证方法,java,android,Java,Android,在比较值()中方法,我已经比较了TextView的值,但是现在我需要使用按钮单击来验证我的方法 我希望在比较值()上找到所有三个匹配项方法,然后需要调用:- Toast.makeText(getApplicationContext(), "Logged In", Toast.LENGTH_SHORT).show(); 否则 查看我的代码: btnLicenseCheck = (Button) findViewById(R.id.btnLicenseCheck); btnL

比较值()中方法,我已经比较了TextView的值,但是现在我需要使用按钮单击来验证我的方法

我希望在比较值()上找到所有三个匹配项方法,然后需要调用:-

   Toast.makeText(getApplicationContext(), "Logged In", Toast.LENGTH_SHORT).show();
否则

查看我的代码:

    btnLicenseCheck = (Button) findViewById(R.id.btnLicenseCheck);
    btnLicenseCheck.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            // if all 3 matches found then need to show
            // Toast.makeText(getApplicationContext(), "Logged In", Toast.LENGTH_SHORT).show();
            // else
            // Toast.makeText(getApplicationContext(), "Cannot Continue", Toast.LENGTH_SHORT).show();

            LicenseValidation();                                

        }
    });               
}

public void ComparingValues()
{

        editPassword = (EditText) findViewById(R.id.editPassword);
        strPassword = editPassword.getText().toString();

        /*** comparing password ***/
        if(strPassword.equals(textPassword))
        {
          Toast.makeText(getApplicationContext(), "Password Match !",
                            Toast.LENGTH_SHORT).show();
          editPassword.setText(null);
        }
        else 
        {
          Toast.makeText(getApplicationContext(), "Password Does not match !",
                    Toast.LENGTH_SHORT).show();
        }

        /*** comparing deviceID ***/
        if(strDeviceID.equals(textDeviceID))
        {
            Toast.makeText(getApplicationContext(), "DeviceID Match", Toast.LENGTH_SHORT).show();
        }
        else
        {
            Toast.makeText(getApplicationContext(), "DeviceID Does not match", Toast.LENGTH_SHORT).show();
        }

        /*** comparing emailID ***/
        if(strEmailID.equals(textEmailID))
        {
            Toast.makeText(getApplicationContext(), "EmailID Match", Toast.LENGTH_SHORT).show();
        }
        else
        {
            Toast.makeText(getApplicationContext(), "EmailID Does not match", Toast.LENGTH_SHORT).show();
        }
    }
}
在onclick内,单击“执行此操作”

if(strPassword.equals(textPassword)&&strDeviceID.equals(textDeviceID) && strEmailID.equals(textEmailID))
{

Toast.makeText(getApplicationContext(), "Logged In", Toast.LENGTH_SHORT).show();
}
else
 Toast.makeText(getApplicationContext(), "Cannot Continue", Toast.LENGTH_SHORT).show();
使用以下命令:

    if(strPassword.equals(textPassword) && strDeviceID.equals(textDeviceID) && strEmailID.equals(textEmailID))

    {
    Toast.makeText(getApplicationContext(), "Logged In", Toast.LENGTH_SHORT).show();
    editPassword.setText(null);
    }
    else if(!strPassword.equals(textPassword))
    {
      Toast.makeText(getApplicationContext(), "Password Does not match !",
                Toast.LENGTH_SHORT).show();
    }

    else if(!strDeviceID.equals(textDeviceID))
    {
        Toast.makeText(getApplicationContext(), "DeviceID Does not match", Toast.LENGTH_SHORT).show();
    }
    else if(strEmailID.equals(textEmailID))
    {
        Toast.makeText(getApplicationContext(), "EmailID Does not match", Toast.LENGTH_SHORT).show();
    }
else{
Toast.makeText(getApplicationContext(), "Cannot Continue", Toast.LENGTH_SHORT).show();
}

现在有什么问题吗?你有什么错误吗?是的,但是为了显示每个匹配的状态,我还显示了比较值();方法,但为了显示每个匹配的状态,我还显示了ComparingValues();onClick()中的方法
    if(strPassword.equals(textPassword) && strDeviceID.equals(textDeviceID) && strEmailID.equals(textEmailID))

    {
    Toast.makeText(getApplicationContext(), "Logged In", Toast.LENGTH_SHORT).show();
    editPassword.setText(null);
    }
    else if(!strPassword.equals(textPassword))
    {
      Toast.makeText(getApplicationContext(), "Password Does not match !",
                Toast.LENGTH_SHORT).show();
    }

    else if(!strDeviceID.equals(textDeviceID))
    {
        Toast.makeText(getApplicationContext(), "DeviceID Does not match", Toast.LENGTH_SHORT).show();
    }
    else if(strEmailID.equals(textEmailID))
    {
        Toast.makeText(getApplicationContext(), "EmailID Does not match", Toast.LENGTH_SHORT).show();
    }
else{
Toast.makeText(getApplicationContext(), "Cannot Continue", Toast.LENGTH_SHORT).show();
}