android – 在尝试将一些代码放入builder.setPositiveButton的onClick()方法时获取’无法解析方法’addOnCompletionListener()’…’

android – 在尝试将一些代码放入builder.setPositiveButton的onClick()方法时获取’无法解析方法’addOnCompletionListener()’…’,第1张

概述我正在尝试在AlertDialog.Builder的builder.setPositiveButton方法中放置一些代码. 问题是我收到以下错误:无法解析方法’addOnCompletionListener(匿名android.content.DialogInterface.OnClickListener,匿名com.google.android.gms.tasks.OnCompletionLis 我正在尝试在AlertDialog.Builder的builder.setPositivebutton方法中放置一些代码.

问题是我收到以下错误:无法解析方法’addOnCompletionListener(匿名android.content.DialogInterface.OnClickListener,匿名com.Google.androID.gms.tasks.OnCompletionListener< com.Google.firebase.auth.AuthResult> )

这是代码:

AlertDialog.Builder builder = new AlertDialog.Builder(SignUpActivity.this);                builder.setTitle("Title");                builder.setVIEw(R.layout.customlayout);                builder.setPositivebutton("Continue",new DialogInterface.OnClickListener() {                    @OverrIDe                    public voID onClick(DialogInterface dialogInterface,int i) {//error from below line                   mAuth.@R_403_3640@WithEmailAndPassword(userEmail.getText().toString(),userPassword.getText().toString())                                .addOnCompleteListener(this,new OnCompleteListener<AuthResult>() {                                    @OverrIDe                                    public voID onComplete(@NonNull Task<AuthResult> task) {                                        Log.d("signUpSuccessful","@R_403_3640@WithEmail:onComplete:" + task.isSuccessful());                                        // If sign in fails,display a message to the user. If sign in succeeds                                        // the auth state Listener will be notifIEd and logic to handle the                                        // signed in user can be handled in the Listener.                                        if (!task.isSuccessful()) {                                            Snackbar snackbar = Snackbar                                                    .make(coordinatorLayout,"Sign up Failed. Please retry.",Snackbar.LENGTH_SHORT);                                            snackbar.show();                                        }                                        // ...                                    }                                });//upto this line                    }                });                AlertDialog dialog = builder.create();                dialog.show();

这有什么不对?

请告诉我.

解决方法
addOnCompleteListener(this,new OnCompleteListener<AuthResult>()

这行中的“this”表示你的DialogInterface.OnClickListener,你应该检查这个方法需要什么样的params,如果是Context,试着把它改成这个

addOnCompleteListener(YourActivityname.this,new OnCompleteListener<AuthResult>()
总结

以上是内存溢出为你收集整理的android – 在尝试将一些代码放入builder.setPositiveButton的onClick()方法时获取’无法解析方法’addOnCompletionListener()’…’全部内容,希望文章能够帮你解决android – 在尝试将一些代码放入builder.setPositiveButton的onClick()方法时获取’无法解析方法’addOnCompletionListener()’…’所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1138023.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存