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 :

Widget pour valider un formulaire


Sujet :

Android

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Août 2009
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2009
    Messages : 23
    Par défaut Widget pour valider un formulaire
    Bonjour à tous,

    Je souhaiterais faire en sorte que mes boutons de validation de formulaire soient indépendants du scrolling tel que dans l'image ci-dessous :

    http://d339vfjsz5zott.cloudfront.net...oid-SDK_04.jpg

    (On retrouve le même type de boutons dans les applications Contact, Agenda etc. fournit par défaut)

    Comment faire ? J'ai entendu parler des actions bar mais j'ai pas l'impression qu'elle soit utilisées pour ça.

    Merci d'avance pour vos réponses.

  2. #2
    Rédacteur
    Avatar de David55
    Homme Profil pro
    Ingénieur informatique
    Inscrit en
    Août 2010
    Messages
    1 542
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2010
    Messages : 1 542
    Par défaut
    Bonjour,

    Essayes en utilisant un scoll view pour ton formulaire et un linear ou relative layout pour tes boutons!

    Par exemple:

    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
     
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_height="wrap_content" android:layout_width="fill_parent">
         <TextView android:id="@+id/TextView01" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Header de la page fixe" />
         <ScrollView android:layout_marginBottom="50dip" android:id="@+id/ScrollView01" android:layout_height="wrap_content" android:layout_width="fill_parent">
              <RadioGroup android:id="@+id/RadioGroup01" android:layout_width="wrap_content" android:layout_height="wrap_content">
                   <RadioButton android:id="@+id/RadioButton01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 1" />
                   <RadioButton android:id="@+id/RadioButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 2" />
                   <RadioButton android:id="@+id/RadioButton03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 3" />
                   <RadioButton android:id="@+id/RadioButton04" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 4" />
                   <RadioButton android:id="@+id/RadioButton05" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 5" />
                   <RadioButton android:id="@+id/RadioButton06" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 6" />
                   <RadioButton android:id="@+id/RadioButton07" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 7" />
                   <RadioButton android:id="@+id/RadioButton08" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 8" />
                   <RadioButton android:id="@+id/RadioButton09" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 9" />
                   <RadioButton android:id="@+id/RadioButton10" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 10" />
                   <RadioButton android:id="@+id/RadioButton11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 11" />
                   <RadioButton android:id="@+id/RadioButton12" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 12" />
                   <RadioButton android:id="@+id/RadioButton13" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 13" />
                   <RadioButton android:id="@+id/RadioButton14" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Radio Button 14" />       
              </RadioGroup>
         </ScrollView>
         <RelativeLayout android:layout_marginTop="-50dip" android:gravity="bottom" android:layout_height="wrap_content" android:layout_width="fill_parent">
            <Button android:id="@+id/Button01" android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="Buton fixe en bas de la page"/>
         </RelativeLayout>
    </LinearLayout>

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Août 2009
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2009
    Messages : 23
    Par défaut
    Merci ça fonctionne. Par contre je comprends pas très bien pourquoi...

    J'ai remarqué que mes boutons n'était pas masqué par le clavier dès lors qu'il étaient placés au-dessus du reste du formulaire (par exemple lorsqu'on retire le margin bottom du scrollview). C'est donc une sorte de "Hack" les margins qui s'annulent mutuellement ?

  4. #4
    Rédacteur
    Avatar de David55
    Homme Profil pro
    Ingénieur informatique
    Inscrit en
    Août 2010
    Messages
    1 542
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2010
    Messages : 1 542
    Par défaut
    C'est la magie des relativeLayout

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Août 2009
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2009
    Messages : 23
    Par défaut
    Et bien en fait j'ai utilisé un LinearLayout comme ci-dessous :

    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
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_height="fill_parent" android:layout_width="fill_parent">
     
        <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="50dip" >
     
    	    ...
     
        </ScrollView>
     
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" ></LinearLayout>
     
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_marginTop="-50dip"
            android:gravity="bottom"
            android:orientation="horizontal"
            android:background="#CCCCCC"
            android:paddingTop="4dp" >
     
                <Button
                    android:id="@+id/new_record_ok"
                    android:layout_width="0dip"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="@string/OK" />
     
                <Button
                    android:id="@+id/new_record_cancel"
                    android:layout_width="0dip"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="@string/cancel" />
     
        </LinearLayout>
     
    </LinearLayout>
    Donc y'a vraiment une magie incompréhensible...

    J'ai également utilisé un layout vide pour coller mes boutons à la fin du formulaire mais du coup j'ai un avertissement. Est-ce qu'il existe une solution plus élégante ? ^^

  6. #6
    Rédacteur
    Avatar de David55
    Homme Profil pro
    Ingénieur informatique
    Inscrit en
    Août 2010
    Messages
    1 542
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2010
    Messages : 1 542
    Par défaut
    Alors la magie des ScrollView :p

    Essayes de supprimer ton LinearLayout en pus et modifie le android:layout_height de ton LinearLayout
    avec comme valeur "fill_parent"

Discussions similaires

  1. [XHTML 1.0] lien non idempotent (pour valider un formulaire par exemple)
    Par pokraka dans le forum Balisage (X)HTML et validation W3C
    Réponses: 0
    Dernier message: 18/04/2010, 08h29
  2. [AC-2003] Critère pour valider un formulaire
    Par Soulq dans le forum VBA Access
    Réponses: 9
    Dernier message: 09/07/2009, 15h23
  3. Bouton pour valider un formulaire
    Par Socki dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 12/06/2009, 17h04
  4. Aide pour valider un formulaire
    Par utzal dans le forum Langage
    Réponses: 8
    Dernier message: 03/04/2007, 09h44
  5. [WebForms]Comment utiliser la touche entrée pour valider un formulaire ?
    Par yonialhadeff dans le forum Général Dotnet
    Réponses: 3
    Dernier message: 10/05/2006, 12h29

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