-2
Good afternoon, I’m having trouble settling an issue. I’m inside a fragment programming my delete account button, but it’s not working, nothing happens when I click on it, I think there’s something smashed.If anyone can help me thank me.
buttonExcluirConta.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
dialog.setTitle("Certeza?");
dialog.setMessage("Deletar");
dialog.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
firebaseUser.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
Toast.makeText(getContext(), "Conta Excluida", Toast.LENGTH_LONG).show();
Intent intent = new Intent(getContext(), Login.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}else{
Toast.makeText(getContext(),task.getException().getMessage(), Toast.LENGTH_LONG).show();
}
}
});
}
});
// removeConta();
}
});
In this case this code is inside a Fragment.java It is correct that I present you this way getActivity as low?
new Alertdialog.Builder(getActivity());
I put the dialog.();
Only the dialog went red...
The.show() dialog command must be directly below the dialog command.Setpositivebutton ... If it was marked in red it is because it was outside the scope of the Onclick method.
– Tiago Loureiro