Partage
  • Partager sur Facebook
  • Partager sur Twitter

[Android] Poblème avec un DialogFrament

Impossible de récuperer les valeurs remplis dans la "pop up"

    8 février 2013 à 10:20:48

    Bonjour à tous,

    Je suis entrain de faire une sorte de pop up pour l'identification. Je me suis basé sur les explications du "man":

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

    Mais voilà, une fois la pop up et la gestion des événements fait, impossible de récupérer l'identifiant et le mot de passe rentrer par l'utilisateur.

    Le layout:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top|center"
            android:contentDescription="@string/logo"
            android:scaleType="center"
            android:src="@drawable/logo" />
    
        <EditText
            android:id="@+id/edtIdentifiant"
            android:inputType="textEmailAddress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginBottom="4dp"
            android:hint="@string/identifiant" />
        <EditText
            android:id="@+id/edtMotdepasse"
            android:inputType="textPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginBottom="16dp"
            android:fontFamily="sans-serif"
            android:hint="@string/motdepasse"/>
    </LinearLayout>

    La class:

    public class PopUpConnexion extends DialogFragment {
    	
    	private EditText identifiant;
    	
    	
    	@Override
    	public Dialog onCreateDialog(Bundle savedInstanceState) {
    	    AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());
    	    // Get the layout inflater
    	    LayoutInflater inflater = this.getActivity().getLayoutInflater();
    	    
    	    // Inflate and set the layout for the dialog
    	    // Pass null as the parent view because its going in the dialog layout
    	    
    	    
    	    builder.setView(inflater.inflate(R.layout.popup_connexion, null))
    	    // Add action buttons
    	           .setPositiveButton(R.string.connexion, new DialogInterface.OnClickListener() {
    	               @Override
    	               public void onClick(DialogInterface dialog, int id) {
    	            	   
    	               }
    	           })
    	           .setNegativeButton(R.string.annuler, new DialogInterface.OnClickListener() {
    	               public void onClick(DialogInterface dialog, int id) {
    	            	   PopUpConnexion.this.getDialog().cancel();
    	               }
    	           });     
    	    return builder.create();
    	}
    	
    }

    J'ai essayer de récupérer les valeurs par tous les moyens mais l'objet identifiant de type EditText est toujours null.

    Merci d'avance


    • Partager sur Facebook
    • Partager sur Twitter

    [Android] Poblème avec un DialogFrament

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown