IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Plusieurs Alertdialog récupérations données


Sujet :

Android

  1. #1
    Membre régulier
    Homme Profil pro
    Software Engineer
    Inscrit en
    Février 2013
    Messages
    139
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Février 2013
    Messages : 139
    Points : 94
    Points
    94
    Par défaut Plusieurs Alertdialog récupérations données
    Bonjour,

    Je souhaite affiché plusieurs Alertdialog les unes à la suite des autres suivant un nombre que j'aurai rentré. Cependant, avec mon code actuelle j'ai deux soucis : la première Alert à s'afficher est la dernière, et lorsque j'appui sur "OK" pour confirmer mes données rentré l'application se ferme.

    Le code :

    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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    package com.example.convertisseurpuissance;
     
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.content.Context;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.EditText;
    import android.widget.ImageView;
     
    public class OptionActivity extends Activity implements OnClickListener{
     
    	final Context context = this;
    	int z = 1;
     
     
    	public void onCreate(Bundle savedInstanceState)
    	{
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_options);
     
    		final ImageView retour = (ImageView) findViewById(R.id.retour);
    		final ImageView validepalier = (ImageView) findViewById(R.id.validepalier);
    		final ImageView validetm = (ImageView) findViewById(R.id.validetm);
     
    		retour.setOnClickListener(this);
    		validepalier.setOnClickListener(this);
    		validetm.setOnClickListener(this);
     
     
     
    	}
     
    	public void onClick(View v) {
     
    		EditText palier = (EditText) findViewById(R.id.palier);
    		String pl = palier.getText().toString();
    		int paliers = Integer.parseInt(pl);
     
     
    		Intent intent = new Intent();
     
    		switch (v.getId()){
     
    			case R.id.retour:
    				intent = new Intent(OptionActivity.this, MainActivity.class);
    				startActivity(intent);
    				break;
    			case R.id.validepalier:
     
     
    				for(z=1;z<=paliers;z++){
     
    					//Layout en tant que view
    					LayoutInflater factory = LayoutInflater.from(this);
    					final View alertDialogView = factory.inflate(R.layout.alertdialogperso,null);
     
    					//Creation de l'alertdialog
    					AlertDialog.Builder adb = new AlertDialog.Builder(this);
     
    					//Affectation de la vue perso à l'alertdialog
    					adb.setView(alertDialogView);
     
    					//Titre AlertDialog
    					adb.setTitle("Level "+z);
     
    					//Icone
    					adb.setIcon(android.R.drawable.ic_dialog_alert);
     
    					//bouton OK
    					adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {
     
    						@Override
    						public void onClick(DialogInterface dialog, int which) {
     
    							EditText puissance = (EditText) alertDialogView.findViewById(R.id.puissanceval);
    							EditText temps = (EditText) alertDialogView.findViewById(R.id.tempsval);
     
    							if(z==1){
    								EditText ppalier = (EditText) findViewById(R.id.ppalier1);
    								EditText tpalier = (EditText) findViewById(R.id.tpalier1);
    								ppalier.setText(puissance.getText().toString());
    								tpalier.setText(temps.getText().toString());
     
    							}else if(z==2){
    								EditText ppalier = (EditText) findViewById(R.id.ppalier2);
    								EditText tpalier = (EditText) findViewById(R.id.tpalier2);
    								ppalier.setText(puissance.getText().toString());
    								tpalier.setText(temps.getText().toString());
     
    							}else if(z==3){
    								EditText ppalier = (EditText) findViewById(R.id.ppalier3);
    								EditText tpalier = (EditText) findViewById(R.id.tpalier3);
    								ppalier.setText(puissance.getText().toString());
    								tpalier.setText(temps.getText().toString());
     
    							}else if(z==4){
    								EditText ppalier = (EditText) findViewById(R.id.ppalier4);
    								EditText tpalier = (EditText) findViewById(R.id.tpalier4);
    								ppalier.setText(puissance.getText().toString());
    								tpalier.setText(temps.getText().toString());
     
    							}else if(z==5){
    								EditText ppalier = (EditText) findViewById(R.id.ppalier5);
    								EditText tpalier = (EditText) findViewById(R.id.tpalier5);
    								ppalier.setText(puissance.getText().toString());
    								tpalier.setText(temps.getText().toString());
     
    							}else if(z==6){
    								EditText ppalier = (EditText) findViewById(R.id.ppalier6);
    								EditText tpalier = (EditText) findViewById(R.id.tpalier6);
    								ppalier.setText(puissance.getText().toString());
    								tpalier.setText(temps.getText().toString());
     
    							}else if(z==7){
    								EditText ppalier = (EditText) findViewById(R.id.ppalier7);
    								EditText tpalier = (EditText) findViewById(R.id.tpalier7);
    								ppalier.setText(puissance.getText().toString());
    								tpalier.setText(temps.getText().toString());
     
    							}else if(z==8){
    								EditText ppalier = (EditText) findViewById(R.id.ppalier8);
    								EditText tpalier = (EditText) findViewById(R.id.tpalier8);
    								ppalier.setText(puissance.getText().toString());
    								tpalier.setText(temps.getText().toString());
     
    							}
    						}
    					});
     
    				adb.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
     
    					@Override
    					public void onClick(DialogInterface dialog, int which) {
    						finish();						
    					}
    				});
     
    				adb.show();
    				}
    				break;
     
    				case R.id.validetm:
     
    				EditText tm = (EditText) findViewById(R.id.tm);
    				break;
    		}
     
     
    	}
     
    }
    Pourriez-vous m'aider ?

    Merci d'avance.

  2. #2
    Expert éminent

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Points : 9 149
    Points
    9 149
    Par défaut
    Bonjour,

    As trop abusé d'alerte dialogue cela peut décourager l'utilisateur car cela demande pas mal d'intéraction...

    Sinon peux tu nous montrer ton logcat ?
    Responsable Android de Developpez.com (Twitter et Facebook)
    Besoin d"un article/tutoriel/cours sur Android, consulter la page cours
    N'hésitez pas à consulter la FAQ Android et à poser vos questions sur les forums d'entraide mobile d'Android.

  3. #3
    Membre régulier
    Homme Profil pro
    Software Engineer
    Inscrit en
    Février 2013
    Messages
    139
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Février 2013
    Messages : 139
    Points : 94
    Points
    94
    Par défaut
    j'ai résolu mon problème, c'est pas évident plusieurs alertdialog qui se suivent mais ca fonctionne bien.

  4. #4
    Membre régulier
    Homme Profil pro
    Software Engineer
    Inscrit en
    Février 2013
    Messages
    139
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Février 2013
    Messages : 139
    Points : 94
    Points
    94
    Par défaut
    Je met mon code au cas où ça serve à quelqu'un :

    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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    //////////////////////////ALERTDIALOG 8//////////////////////////
     
    					//Layout en tant que view
    					LayoutInflater factory8 = LayoutInflater.from(this);
    					final View alertDialogView8 = factory8.inflate(R.layout.alertdialogperso,null);
    					//Creation de l'alertdialog
    					AlertDialog.Builder adb8 = new AlertDialog.Builder(this);
    					//Affectation de la vue perso à l'alertdialog
    					adb8.setView(alertDialogView8);
    					//Titre AlertDialog
    					adb8.setTitle("Level 8");
    					//Icone
    					adb8.setIcon(android.R.drawable.ic_dialog_alert);
    					//bouton OK
    					adb8.setPositiveButton("OK", new DialogInterface.OnClickListener() {
     
    					EditText puissance = (EditText) alertDialogView8.findViewById(R.id.puissanceval);
    					EditText temps = (EditText) alertDialogView8.findViewById(R.id.tempsval);
     
    						@Override
    						public void onClick(DialogInterface dialog, int which) {
     
     
     
    								TextView palierp8 = (TextView) findViewById(R.id.ppalier8);
    								TextView paliert8 = (TextView) findViewById(R.id.tpalier8);
    								palierp8.setText(puissance.getText().toString()+"%");
    								paliert8.setText(temps.getText().toString()+"s");
     
     
    						}
     
     
    					});
     
    					adb8.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
     
    					@Override
    					public void onClick(DialogInterface dialog, int which) {
    						finish();						
    					}
    					});
     
     
    					if(paliers==1){
    						adb1.show();
    					}else if(paliers==2){
    						adb2.show();
    						adb1.show();
    					}else if(paliers==3){
    						adb3.show();
    						adb2.show();
    						adb1.show();
    					}else if(paliers==4){
    						adb4.show();
    						adb3.show();
    						adb2.show();
    						adb1.show();
    					}else if(paliers==5){
    						adb5.show();
    						adb4.show();
    						adb3.show();
    						adb2.show();
    						adb1.show();
    					}else if(paliers==6){
    						adb6.show();
    						adb5.show();
    						adb4.show();
    						adb3.show();
    						adb2.show();
    						adb1.show();
    					}else if(paliers==7){
    						adb7.show();
    						adb6.show();
    						adb5.show();
    						adb4.show();
    						adb3.show();
    						adb2.show();
    						adb1.show();
    					}else if(paliers==8){
    						adb8.show();
    						adb7.show();
    						adb6.show();
    						adb5.show();
    						adb4.show();
    						adb3.show();
    						adb2.show();
    						adb1.show();
     
    					}
    				}
    Il faut bien afficher les alertdialog dans le sens inverse du coup vu qu'elles s'empilent.

  5. #5
    Expert éminent

    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Février 2007
    Messages
    4 253
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2007
    Messages : 4 253
    Points : 7 618
    Points
    7 618
    Billets dans le blog
    3
    Par défaut
    Non, il faut bien les afficher les unes après les autres... et attendre que la précédente soit fermée pour afficher la suivante. Certaines versions du SDK n'acceptent pas l'empilement des Alerts...

    De plus je ne comprends pas l'interêt des "Alertes" ici... qui me semblent contre productives...

    Pour rappel sur les alertes:
    http://developer.android.com/design/...gs.html#alerts

    Et elles ne doivent se produire qui si on est dans une case "confirm":
    N'oubliez pas de cliquer sur mais aussi sur si un commentaire vous a été utile !
    Et surtout

  6. #6
    Membre régulier
    Homme Profil pro
    Software Engineer
    Inscrit en
    Février 2013
    Messages
    139
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Février 2013
    Messages : 139
    Points : 94
    Points
    94
    Par défaut
    En fait j'avais besoin de plusieurs alertdialog car je trouvais cela plus simple et ergonomique dans mon cas, je m'explique, l'utilisateur choisi un certain nombre de paliers, et ensuite suivant ce nombre j'affiche les unes sur les autres autant d'alertdialog, je récupère deux informations dans ces alertdialog que je stock sur ma vue ainsi que dans mes préférences.

  7. #7
    Expert éminent

    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Février 2007
    Messages
    4 253
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2007
    Messages : 4 253
    Points : 7 618
    Points
    7 618
    Billets dans le blog
    3
    Par défaut
    Ouais... une simple liste, avec un bouton d'ajout de palier (dynamique) me semble plus ergonomique
    N'oubliez pas de cliquer sur mais aussi sur si un commentaire vous a été utile !
    Et surtout

  8. #8
    Membre régulier
    Homme Profil pro
    Software Engineer
    Inscrit en
    Février 2013
    Messages
    139
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Software Engineer
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Février 2013
    Messages : 139
    Points : 94
    Points
    94
    Par défaut
    Oui surrement mais ca aurait été petit sur la 7 pouce et ca m'a fait travailler sur les alertdialogs et sur les préférences

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2000] Récupération données plusieurs fichiers excel
    Par flosauveur69 dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 20/09/2010, 14h13
  2. Réponses: 3
    Dernier message: 13/09/2005, 12h21
  3. connexion a plusieurs bases de données oracle
    Par tarik75 dans le forum JDBC
    Réponses: 1
    Dernier message: 06/07/2005, 13h33
  4. Réponses: 2
    Dernier message: 24/05/2005, 16h35
  5. triggers sur plusieurs bases de données
    Par Shabata dans le forum Langage SQL
    Réponses: 2
    Dernier message: 04/05/2004, 10h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo