不兼容的类型:EditText不能转换为String

时间:2019-07-17 02:47:06

标签: android android-edittext firebase-authentication

firebaseAuth.signInWithEmailAndPassword(Username, Password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {
                if (task.isSuccessful()){
                    progressDialog.dismiss();
                    Toast.makeText(MainActivity.this, "Login Success", Toast.LENGTH_SHORT).show();
                    startActivity(new Intent(MainActivity.this, SecondActivity.class));
                } else {
                    Toast.makeText(MainActivity.this, "Login Failed", Toast.LENGTH_SHORT).show();
                    counter--;
                    Attempt.setText("No of attempts remaining : " +counter);
                    progressDialog.dismiss();
                    if (counter==0)
                        Login.setEnabled(false);

我放置了此代码,但仍然遇到相同的错误

Login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                validate(Username.getText().toString(), Password.getText().toString());
            }
        });

起初它是有效的,但是由于我用signInWithEmail替换了createUserWithEmail ....,因此出现此错误

1 个答案:

答案 0 :(得分:1)

将代码更改为

firebaseAuth.signInWithEmailAndPassword(Username.getText().toString(), Password.getText().toString())

您不能将editText作为参数传递,因为Username和password是EditText,它们将从中提取值并发送。