récupérer une valeur saisie dans alertdialog
Bonjour,
voici le code en question
je créer un alertdialog (qui fonctionne) pour saisir une info pour la récupérer .
Code:
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
|
private void ajouterdansserie() {
// TODO Auto-generated method stub
//On instancie notre layout en tant que View
LayoutInflater factory = LayoutInflater.from(this);
final View alertDialogView = factory.inflate(R.layout.dialogajoutxml, null);
//Création de l'AlertDialog
AlertDialog.Builder adb = new AlertDialog.Builder(this);
//On affecte la vue personnalisé que l'on a crée à notre AlertDialog
adb.setView(alertDialogView);
//On donne un titre à l'AlertDialog
adb.setTitle("Ajout d'une Valeur");
//On modifie l'icône de l'AlertDialog pour le fun ;)
adb.setIcon(android.R.drawable.ic_dialog_alert);
//On affecte un bouton "OK" à notre AlertDialog et on lui affecte un évènement
adb.setPositiveButton("Valider", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//Lorsque l'on cliquera sur le bouton "OK", on récupère l'EditText correspondant à notre vue personnalisée (cad à alertDialogView)
EditText valsaisie = (EditText)alertDialogView.findViewById(R.id.EditTextajout);
Log.i("","nouvelle valeur recuperere"+valsaisie);
//On affiche dans un Toast le texte contenu dans l'EditText de notre AlertDialog
//Toast.makeText(this, valsaisie.getText(), Toast.LENGTH_SHORT).show();
} });
//On crée un bouton "Annuler" à notre AlertDialog et on lui affecte un évènement
adb.setNegativeButton("Annuler", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//Lorsque l'on cliquera sur annuler on quittera l'application
//finish();
} });
adb.show();
} |
je récupérer une valeur autre que celle saisie en loccurence
Code:
1 2
|
03-20 09:48:05.167: INFO/(4989): nouvelle valeur recuperereandroid.widget.EditText@44f6f5c0 |
j'ai une erreur dans mon code ????
merci