Comment vérifier si AlertDialog.builder est en train de l'afficher et de l'annuler s'il est affiché?
Voici mon code -
View layout = LayoutInflater.from(this).inflate(R.layout.dialog_loc_info, null);
final Button mButton_Mobile = (Button) layout.findViewById(R.id.button);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(layout);
mButton_Mobile.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
if(builder.)
showDialog(); //this is another dialog, nothing to do with this code
}
});
builder.setNeutralButton(getString(android.R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.show();
source d'informationauteur Darpan
Vous devez vous connecter pour publier un commentaire.
Vous pouvez utiliser
AlertDialog
méthodes pour cela.Espère que cela aide.
Une approche alternative est d'utiliser une méthode pour générer l'AlertDialog avec un constructeur, puis créer l'AlertDialog sans la montrer pendant le réglage de l'AlertDialog à une variable de classe.
Puis vérifier avec
.isShowing();
méthodeExemple:
espère qu'il est bien compris comment utiliser cette source.
cheers
AlertDialog
s'étendDialog
qui a isShowing().Astuce:
AlertDialog.Builder
crée unAlertDialog
instance. 🙂Vous pouvez le vérifier avec cette: