Jump to content

Afficher une information speciale


clavat

Recommended Posts

Bonjour c'est peut être une question facile à répondre mais je ne trouve pas xD

j'aimerais afficher un texte au milieu de l'écran avec un bouton afin de confirmer

je connais les Toast mais l'affichage ce fait en bas et sans bouton...

Merci de votre aide !

Link to comment
Share on other sites

Un bon p'tit dialog ne ferait pas l'affaire ?

http://developer.android.com/guide/topics/ui/dialogs.html

Adding buttons

To create an AlertDialog with side-by-side buttons like the one shown in the screenshot to the right, use the set...Button() methods:

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?")
      .setCancelable(false)
      .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
               MyActivity.this.finish();
          }
      })
      .setNegativeButton("No", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
               dialog.cancel();
          }
      });
AlertDialog alert = builder.create();
First, add a message for the dialog with setMessage(CharSequence). Then, begin method-chaining and set the dialog to be not cancelable (so the user cannot close the dialog with the back button) with setCancelable(boolean). For each button, use one of the set...Button() methods, such as setPositiveButton(), that accepts the name for the button and a DialogInterface.OnClickListener that defines the action to take when the user selects the button.

Note: You can only add one of each button type to the AlertDialog. That is, you cannot have more than one "positive" button. This limits the number of possible buttons to three: positive, neutral, and negative. These names are technically irrelevant to the actual functionality of your buttons, but should help you keep track of which one does what.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...