Bonjour,
je suis débutant en Java Android, et j'aimerais qu'au clic du Bouton "Quitter", dans la boîte de dialogue qui s'affiche, un EditText pour saisir du texte (je verais ensuite pour vérifier le texte saisie), mais également qu'après la confirmation avec le bouton "Confirmer", un Toast s'affiche en bas de l'écran quelques secondes.
Voici mon code java du bouton Quitter :
et mon activity_main.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 package com.test.motdepasse; /** * Created by DB020490 on 11/02/2016. */ import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.v4.app.DialogFragment; public class AlertDFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) // Set Dialog Title .setTitle(R.string.Confirmer) // Set Dialog Message .setMessage(R.string.Fermer_Application) // Positive button .setPositiveButton(R.string.Confirmer, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { System.exit(0); // Do something else } }) // Negative Button .setNegativeButton(R.string.Annuler, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Do something else } }).create(); } }
Merci de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/app"> <Button android:id="@+id/ChangerLangue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="@string/ChangerLaLangue" /> <Button android:id="@+id/alertdfragbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_below="@+id/ChangerLangue" android:text="@string/Quitter" /> </RelativeLayout>
Partager