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 :

Problèmes de mise en page


Sujet :

Android

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Janvier 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2014
    Messages : 7
    Points : 5
    Points
    5
    Par défaut Problèmes de mise en page
    Bonjour a tous,

    Je suis un débutant en programmation sous Android et je me retrouve confronté à un souci concernant la mise en page de mon "Activity".

    Mon appli est une "Activity" qui comprend 12 TextView, 12 EditText, 2 CheckBox, 2 GridView, 1 Spinner et un Button.
    Voici mon code:
    String.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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
     
        <string name="app_name">TestPositionnement</string>
        <string name="hello_world">Hello world!</string>
        <string name="action_settings">Settings</string>
     
        <!-- Info des boutons -->
        <string name="save">Sauvegarde</string>
     
        <!-- Info pour la partie Particulier de Interieur du Bien -->
        <string name="surf_hab">Surface habitable</string>
        <string name="surf_sej">Surface séjour</string>
        <string name="wc">WC</string>
        <string name="garage">Garage(s)</string>
        <string name="piece">Pièce(s)</string>
        <string name="chambre">Chambre(s)</string>
        <string name="park_int">Parking intérieur</string>
        <string name="park_ext">Parking extérieur</string>
        <string name="sdb">Salle(s) de bains</string>
        <string name="sd">Salle(s) d\'eau</string>
        <string name="ch_rdc">Chambre(s) en RDC</string>
        <string name="etage">Etage(s)</string>
        <string name="plain_pied">Plain pied</string>
        <string name="sur_sous_sol">Sur sous-sol</string>
        <string name="cuisine">Cuisine</string>
        <string-array name="liste_cui">
            <item>Aménagée</item>
            <item>Equipée</item>
            <item>Américaine</item>
            <item>Coin cuisine</item>
            <item>Vide</item>
        </string-array>
        <string name="type_chauff">Type de chauffage</string>
        <string-array name="liste_type_chauff">
            <item>Bois</item>
            <item>Gaz</item>
            <item>Fuel</item>
            <item>Electrique</item>
            <item>Cheminée</item>
            <item>Clim. reversible</item>
            <item>Sol</item>
            <item>Solaire</item>
            <item>Géothermie</item>
            <item>Insert</item>
        </string-array>
        <string name="nature_chauff">Nature du chauffage</string>
        <string name="chauffage">Chauffage</string>
        <string-array name="liste_nat_chauff">
            <item>Collectif</item>
            <item>Individuel</item>
            <item>Central</item>
            <item>Aucun</item>
        </string-array>
     
    </resources>
    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
    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
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    	<LinearLayout android:layout_width="wrap_content"
    	    android:layout_height="wrap_content"
    	    android:orientation="vertical"
    	    android:gravity="center" >
     
     
    	    <!-- 1ere ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView
    	        	android:id="@+id/text_view_surf_hab"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/surf_hab" />
     
    	        <EditText
    	            android:id="@+id/surf_hab_edit"
    	            android:layout_width="wrap_content"
    	            android:layout_height="wrap_content"
    	            android:layout_marginRight="25dp"
    	            android:ems="5"
    	            android:inputType="number"
    	            android:textSize="12sp" />
     
    	    </LinearLayout>
     
    	    <!-- 2eme ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView android:id="@+id/text_view_surf_sej"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/surf_sej" />
     
    	        <EditText
    		    	android:id="@+id/surf_sej_edit"
    		    	android:layout_width="wrap_content"
    		    	android:layout_height="wrap_content"
    	            android:layout_marginRight="25dp"
    		    	android:ems="5"
    		    	android:inputType="number"
    		    	android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 3eme ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView android:id="@+id/text_view_wc"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/wc" />
     
    	        <EditText
    		    	android:id="@+id/wc_edit"
    		    	android:layout_width="wrap_content"
    		    	android:layout_height="wrap_content"
    		    	android:ems="5"
    		    	android:inputType="number"
    		    	android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 4eme ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView android:id="@+id/text_view_garage"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/garage" />
     
    	        <EditText
    		    	android:id="@+id/garage_edit"
    		    	android:layout_width="wrap_content"
    		    	android:layout_height="wrap_content"
    		    	android:ems="5"
    		    	android:inputType="number"
    		    	android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 5eme ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView android:id="@+id/text_view_piece"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/piece" />
     
    	        <EditText
    		    	android:id="@+id/piece_edit"
    		    	android:layout_width="wrap_content"
    		    	android:layout_height="wrap_content"
    		    	android:ems="5"
    		    	android:inputType="number"
    		    	android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 6eme ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView android:id="@+id/text_view_chambre"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/chambre" />
     
    	        <EditText
    		    	android:id="@+id/chambre_edit"
    		    	android:layout_width="wrap_content"
    		    	android:layout_height="wrap_content"
    		    	android:ems="5"
    		    	android:inputType="number"
    		    	android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 7eme ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView android:id="@+id/text_view_park_int"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/park_int" />
     
    	        <EditText
    		    	android:id="@+id/park_int_edit"
    		    	android:layout_width="wrap_content"
    		    	android:layout_height="wrap_content"
    		    	android:ems="5"
    		    	android:inputType="number"
    		    	android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 8eme ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView android:id="@+id/text_view_park_ext"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/park_ext" />
     
    	        <EditText
    		    	android:id="@+id/park_ext_edit"
    		    	android:layout_width="wrap_content"
    		    	android:layout_height="wrap_content"
    		    	android:ems="5"
    		    	android:inputType="number"
    		    	android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 9eme ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView android:id="@+id/text_view_sdb"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/sdb" />
     
    	        <EditText
    		    	android:id="@+id/sdb_edit"
    		    	android:layout_width="wrap_content"
    		    	android:layout_height="wrap_content"
    		    	android:ems="5"
    		    	android:inputType="number"
    		    	android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 10eme ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView android:id="@+id/text_view_sd"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/sd" />
     
    	        <EditText
    		    	android:id="@+id/sd_edit"
    		    	android:layout_width="wrap_content"
    		    	android:layout_height="wrap_content"
    		    	android:ems="5"
    		    	android:inputType="number"
    		    	android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 11eme ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView android:id="@+id/text_view_ch_rdc"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/ch_rdc" />
     
    	        <EditText
    		    	android:id="@+id/ch_rdc_edit"
    		    	android:layout_width="wrap_content"
    		    	android:layout_height="wrap_content"
    		    	android:ems="5"
    		    	android:inputType="number"
    		    	android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 12eme ligne = texte + champs editable -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <TextView android:id="@+id/text_view_etage"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/etage" />
     
    	        <EditText
    		    	android:id="@+id/etage_edit"
    		    	android:layout_width="wrap_content"
    		    	android:layout_height="wrap_content"
    		    	android:ems="5"
    		    	android:inputType="number"
    		    	android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 13eme ligne = check box -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <CheckBox
    	        	android:id="@+id/check_box_plain_pied"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/plain_pied" />
    	    </LinearLayout>
     
    	    <!-- 14eme ligne = check box -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent" >
     
    	        <CheckBox
    	        	android:id="@+id/check_box_sur_sous_sol"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:layout_marginLeft="5dp"
    	        	android:text="@string/sur_sous_sol" />
    	    </LinearLayout>
     
    	    <!-- 15eme ligne = texte -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent"
    			android:gravity="center"
    			android:layout_gravity="left">
     
    	        <TextView android:id="@+id/text_view_titre_cuisine"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:text="@string/cuisine" />
    	    </LinearLayout>
     
    	    <!-- 16eme ligne = grid view -->
    	    <LinearLayout android:layout_height="match_parent"
    			android:orientation="horizontal"
    			android:layout_width="match_parent"
    			android:gravity="center"
    			android:layout_gravity="left">
     
    	        <GridView android:id="@+id/liste_cuisine"
    	        	android:layout_width="match_parent"
    	        	android:layout_height="match_parent"
    	        	android:choiceMode="multipleChoice"
    	        	android:entries="@array/liste_cui"
    	        	android:gravity="center"
    	        	android:textSize="8sp"
    	        	android:numColumns="auto_fit"
    	        	android:stretchMode="columnWidth" />
    	    </LinearLayout>
     
    	    <!-- 17eme ligne = texte -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent"
    			android:gravity="center"
    			android:layout_gravity="left">
     
    	        <TextView android:id="@+id/text_view_titre_type_chauff"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:text="@string/type_chauff" />
    	    </LinearLayout>
     
    	    <!-- 18eme ligne = grid view -->
    	    <LinearLayout android:layout_height="match_parent"
    			android:orientation="horizontal"
    			android:layout_width="match_parent"
    			android:gravity="center"
    			android:layout_gravity="left">
     
    	        <GridView android:id="@+id/liste_chauff"
    	        	android:layout_width="match_parent"
    	        	android:layout_height="match_parent"
    	        	android:choiceMode="multipleChoice"
    	        	android:entries="@array/liste_type_chauff"
    	        	android:gravity="center"
    	        	android:textSize="12sp"
    	        	android:numColumns="auto_fit"
    	        	android:stretchMode="columnWidth" />
    	    </LinearLayout>
     
    	    <!-- 19eme ligne = texte -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent"
    			android:gravity="center"
    			android:layout_gravity="left">
     
    	        <TextView android:id="@+id/text_view_titre_nat_chauff"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:text="@string/nature_chauff" />
    	    </LinearLayout>
     
    	    <!-- 20eme ligne = spinner -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent"
    			android:gravity="center"
    			android:layout_gravity="left">
     
    	        <Spinner
    	         	android:id="@+id/spinner_nat_chauff"
    	         	android:layout_width="wrap_content"
    	         	android:layout_height="wrap_content"
    	         	android:prompt="@string/chauffage" />
    	    </LinearLayout>
     
    	    <!-- 21eme ligne = bouton -->
    	    <LinearLayout android:layout_height="wrap_content"
    			android:orientation="horizontal"
    			android:layout_width="match_parent"
    			android:gravity="center"
    			android:layout_gravity="left">
     
    	        <Button
    	        	android:id="@+id/buttonSaveIntBien"
    	        	android:layout_width="wrap_content"
    	        	android:layout_height="wrap_content"
    	        	android:text="@string/save" />
    	    </LinearLayout>
     
    	</LinearLayout>
    </ScrollView>
    MainActivity.java :
    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
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    package com.example.testpositionnement;
     
    import android.app.Activity;
    import android.graphics.Typeface;
    import android.os.Bundle;
    import android.text.SpannableString;
    import android.text.style.StyleSpan;
    import android.text.style.UnderlineSpan;
    import android.view.KeyEvent;
    import android.view.View;
    import android.widget.AdapterView;
    import android.widget.ArrayAdapter;
    import android.widget.Button;
    import android.widget.CheckBox;
    import android.widget.EditText;
    import android.widget.GridView;
    import android.widget.Spinner;
    import android.widget.TextView;
    import android.widget.Toast;
    import android.widget.AdapterView.OnItemClickListener;
    import android.widget.AdapterView.OnItemSelectedListener;
    import android.widget.TextView.OnEditorActionListener;
     
    public class MainActivity extends Activity {
    	TextView titre1;
    	TextView titre2;
    	TextView titre3;
    	EditText surfHab;
    	EditText surfSej;
    	EditText wc;
    	EditText garage;
    	EditText piece;
    	EditText chambre;
    	EditText parkInt;
    	EditText parkExt;
    	EditText sdb;
    	EditText sd;
    	EditText chRDC;
    	EditText etage;
    	CheckBox plainPied;
    	CheckBox surSousSol;
    	GridView table1;
    	GridView table2;
    	String[] elements1;
    	String[] elements2;
    	Spinner spinner;
    	Button save;
     
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);
     
    		// Mettre les titres en gras et souligner
            titre1 = (TextView) findViewById(R.id.text_view_titre_cuisine);
            String tempString1 = titre1.getText().toString();
    		SpannableString spanString1 = new SpannableString(tempString1);
    		spanString1.setSpan(new UnderlineSpan(), 0, spanString1.length(), 0);
    		spanString1.setSpan(new StyleSpan(Typeface.BOLD), 0, spanString1.length(), 0);
    		titre1.setText(spanString1);
    		titre2 = (TextView) findViewById(R.id.text_view_titre_type_chauff);
            String tempString2 = titre2.getText().toString();
    		SpannableString spanString2 = new SpannableString(tempString2);
    		spanString2.setSpan(new UnderlineSpan(), 0, spanString2.length(), 0);
    		spanString2.setSpan(new StyleSpan(Typeface.BOLD), 0, spanString2.length(), 0);
    		titre2.setText(spanString2);
    		titre3 = (TextView) findViewById(R.id.text_view_titre_nat_chauff);
            String tempString3 = titre3.getText().toString();
    		SpannableString spanString3 = new SpannableString(tempString3);
    		spanString3.setSpan(new UnderlineSpan(), 0, spanString3.length(), 0);
    		spanString3.setSpan(new StyleSpan(Typeface.BOLD), 0, spanString3.length(), 0);
    		titre3.setText(spanString3);
     
    		//Ecoute des textedit
    		surfHab = (EditText) findViewById(R.id.surf_hab_edit);
    		surfHab.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (surfHab.getText().toString() != null && surfHab.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
    		surfSej = (EditText) findViewById(R.id.surf_sej_edit);
    		surfSej.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (surfSej.getText().toString() != null && surfSej.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
    		wc = (EditText) findViewById(R.id.wc_edit);
    		wc.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (wc.getText().toString() != null && wc.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
    		garage = (EditText) findViewById(R.id.garage_edit);
    		garage.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (garage.getText().toString() != null && garage.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
    		piece = (EditText) findViewById(R.id.piece_edit);
    		piece.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (piece.getText().toString() != null && piece.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
    		chambre = (EditText) findViewById(R.id.chambre_edit);
    		chambre.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (chambre.getText().toString() != null && chambre.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
    		parkInt = (EditText) findViewById(R.id.park_int_edit);
    		parkInt.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (parkInt.getText().toString() != null && parkInt.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
    		parkExt = (EditText) findViewById(R.id.park_ext_edit);
    		parkExt.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (parkExt.getText().toString() != null && parkExt.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
    		sdb = (EditText) findViewById(R.id.sdb_edit);
    		sdb.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (sdb.getText().toString() != null && sdb.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
    		sd = (EditText) findViewById(R.id.sd_edit);
    		sd.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (sd.getText().toString() != null && sd.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
    		chRDC = (EditText) findViewById(R.id.ch_rdc_edit);
    		chRDC.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (chRDC.getText().toString() != null && chRDC.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
    		etage = (EditText) findViewById(R.id.etage_edit);
    		etage.setOnEditorActionListener(new OnEditorActionListener ()
    		{
    			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    				// Si le champ n'est pas vide
    				if (etage.getText().toString() != null && etage.getText().toString().trim().length() > 0) {
    					// On recupere la valeur de l'EditText
    					//namePlayer1 = name1.getText().toString();
    					return false;
    				}
    				return true;
    			}
    		});
     
    		// Ecoute des CheckBox
    		plainPied = (CheckBox) findViewById(R.id.check_box_plain_pied);
    		plainPied.setOnClickListener(new CheckBox.OnClickListener() {
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				if (plainPied.isChecked()) {
    					// On save les info
    				} else {
    					// On save pas
    				}
    			}
    		});
    		surSousSol = (CheckBox) findViewById(R.id.check_box_sur_sous_sol);
    		surSousSol.setOnClickListener(new CheckBox.OnClickListener() {
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				if (plainPied.isChecked()) {
    					// On save les info
    				} else {
    					// On save pas
    				}
    			}
    		});
     
    		// Ecoute des GridView
    		table1 = (GridView) findViewById(R.id.liste_cuisine);
    		elements1 = getResources().getStringArray(R.array.liste_cui);
    		ArrayAdapter<String> adaptateur1 = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice);
    		for (int i=0; i < elements1.length; i++) {
    			adaptateur1.add(elements1[i]);
    		}
    		table1.setAdapter(adaptateur1);
    		// Ajout du listener sur la grid
    		table1.setOnItemClickListener(new OnItemClickListener() {
    			public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    				Toast.makeText(MainActivity.this, "L'element selectionne est >"+elements1[position]+"<", Toast.LENGTH_SHORT).show();
    			}
    		});
    		table2 = (GridView) findViewById(R.id.liste_chauff);
    		elements2 = getResources().getStringArray(R.array.liste_type_chauff);
    		ArrayAdapter<String> adaptateur2 = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice);
    		for (int i=0; i < elements2.length; i++) {
    			adaptateur2.add(elements2[i]);
    		}
    		table2.setAdapter(adaptateur2);
    		table2.setOnItemClickListener(new OnItemClickListener() {
    			public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    				Toast.makeText(MainActivity.this, "L'element selectionne est >"+elements2[position]+"<", Toast.LENGTH_SHORT).show();
    			}
    		});
     
    		// Creation du spinner
    		spinner = (Spinner) findViewById(R.id.spinner_nat_chauff);
    		// Create an ArrayAdapter using the string array and a default spinner layout
    		ArrayAdapter<CharSequence> adapterSpinner = ArrayAdapter.createFromResource(this, R.array.liste_nat_chauff, android.R.layout.simple_spinner_item);
    		// Specify the layout to use when the list of choices appears
    		adapterSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    		// Apply the adapter to the spinner
    		spinner.setAdapter(adapterSpinner);
    		// Test d'ecoute du spinner
    		spinner.setOnItemSelectedListener(new OnItemSelectedListener ()
    		{
    			public void onItemSelected(AdapterView<?> arg0, View v, int pos, long row)
    			{
    				// Recuperation de la valeur selectionnee
    				//Object itemnom1 = arg0.getItemAtPosition(pos);
    				//sexe1 = String.valueOf(itemnom1);
    			}
    			public void onNothingSelected(AdapterView<?> arg0)
    			{
    			}
    		});
     
    		// Ecoute du bouton save
    		save = (Button) findViewById(R.id.buttonSaveIntBien);
    		save.setOnClickListener(new View.OnClickListener() {
    			public void onClick(View v) {
    				clickSave();
    			}
    		});
    	}
     
    	public void clickSave(){
    		Toast.makeText(MainActivity.this, "La sauvegarde se realise.", Toast.LENGTH_SHORT).show();
    	}
    }
    Maintenant je vais vous présenter mes deux problèmes.

    Mon premier problème se trouve dans les "LinearLayout" qui englobent mes TextView et EditText.
    Dans mon code, je position le TextView à "5dp" du bord gauche et l'EditText à "25dp" du bord droit. Or, lors de l'execution de mon programme, seul le positionnement du TextView est pris en compte.
    J'ai essayé de remplacer
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    android:layout_marginRight="25dp"
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    android:marginRight="25dp"
    mais rien n'y fait...
    Quelqu'un aurait une idée ?

    Mon deuxième problème se trouve dans les GridView.
    Ma première GridView comprend 5 éléments et ma deuxième 10.
    Le problème que j'ai est le suivant: Lors de l’exécution de mon programme, mes GridView ne m'affichent pas l’intégralité de mes éléments.
    En effet, mes deux GridView m'affichent qu'une seule ligne avec deux éléments.
    Quelqu'un aurait une idée pour faire afficher afficher l’intégralité de mes éléments dans la GridView ?

    Je vous remercie d'avance pour votre aide et j'attends avec impatience vos retours !

  2. #2
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2014
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Distribution

    Informations forums :
    Inscription : Octobre 2014
    Messages : 6
    Points : 4
    Points
    4
    Par défaut
    Salut l'ami !
    Je suis débutant aussi cependant je pense savoir pourquoi tes edittexts ne sont pas bien positionner:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    <EditText
    	            android:id="@+id/surf_hab_edit"
    	            android:layout_width="wrap_content"
    	            android:layout_height="wrap_content"
    	            android:layout_marginRight="25dp"// Là est le problème. :)
    	            android:ems="5"
    	            android:inputType="number"
    	            android:textSize="12sp" />
    Par défaut il me semble, les différents éléments de ta vue sont collés les uns aux autres(Corrigez moi si je me trompe), et dans ton cas pour les décoller, il faut utiliser:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    android:layout_marginLeft="25dp"// 25-50-100dp, à toi de tester et d'insérer la valeur que tu souhaites. :)
    Quant à ton problème de GridView je ne vois pas pour le moment, mais surement quelqu'un d'autre pourra te renseigner.
    Amicalement,
    Eazer

  3. #3
    Modérateur
    Avatar de Hizin
    Homme Profil pro
    Développeur mobile
    Inscrit en
    Février 2010
    Messages
    2 180
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur mobile

    Informations forums :
    Inscription : Février 2010
    Messages : 2 180
    Points : 5 072
    Points
    5 072
    Par défaut
    Au lieu d'appliquer indépendamment les ajustements sur chacun de tes composants, applique-les sur le conteneur. Ca facilitera la lecture, la maintenance et devrait résoudre ton problème.
    C'est Android, PAS Androïd, ou Androïde didiou !
    Le premier est un OS, le second est la mauvaise orthographe du troisième, un mot français désignant un robot à forme humaine.

    Membre du comité contre la phrase "ça marche PAS" en titre et/ou explication de problème.

    N'oubliez pas de consulter les FAQ Android et les cours et tutoriels Android

  4. #4
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Janvier 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2014
    Messages : 7
    Points : 5
    Points
    5
    Par défaut
    Salut Eazer,

    Effectivement, en utilisant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    android:layout_marginLeft="25dp"
    cela fonctionne. Mais c'est un peu trop du "bricolage"...
    Mes TextView ne sont pas toutes de la même longueur: l'instruction android:layout_width="wrap_content" demande au Widget de prendre une place "naturelle".
    Ainsi, en utilisant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    android:layout_marginLeft="25dp"
    j'aurai bien le même écart entre mon TextView et mon EditText mais mes EditText ne seront pas alignés les uns par rapport aux autres vu que mes TextView ne sont pas de la même longueur!
    Du coup, j'ai suivi le conseil d'Hizin et j'ai mis mon TextView dans un LinearLayout et mon EditText dans un autre LinearLayout. Comme ça, j'ai pu positionner mon TextView grave à
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    android:layout_marginLeft="25dp"
    et j'ai ensuite positionné mon EditText avec
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    android:layout_marginRight="25dp"
    Maintenant j'ai bien tous mes TextView alignés les uns par rapport aux autres et c'est pareil pour les EditText !
    Voici mon nouveau 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
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
     
    	<LinearLayout
    	    android:layout_width="wrap_content"
    	    android:layout_height="wrap_content"
    	    android:gravity="center"
    	    android:orientation="vertical" >
     
    	    <!-- 1ere ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    	        <LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	            <TextView
    	                android:id="@+id/text_view_surf_hab"
    	                android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	                android:text="@string/surf_hab" />
    	        </LinearLayout>
    	        <LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	            <EditText
    	                android:id="@+id/surf_hab_edit"
    	                android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:layout_marginRight="45dp"
    	                android:ems="5"
    	                android:inputType="number"
    	                android:textSize="12sp" />
    	        </LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 2eme ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    			<LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<TextView
    	            	android:id="@+id/text_view_surf_sej"
    	            	android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	            	android:text="@string/surf_sej" />
    	        </LinearLayout>
    			<LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<EditText
    	            	android:id="@+id/surf_sej_edit"
    	            	android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:layout_gravity="right"
    	                android:layout_marginRight="45dp"
    	                android:ems="5"
    	                android:inputType="number"
    	                android:textSize="12sp" />
    	        	</LinearLayout>
    		</LinearLayout>
     
    	    <!-- 3eme ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    			<LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<TextView
    	           		android:id="@+id/text_view_wc"
    	            	android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	            	android:text="@string/wc" />
    	        </LinearLayout>
    			<LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<EditText
    	            	android:id="@+id/wc_edit"
    	            	android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:layout_gravity="right"
    	                android:layout_marginRight="45dp"
    	                android:ems="5"
    	            	android:inputType="number"
    	            	android:textSize="12sp" />
    	        </LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 4eme ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    			<LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<TextView
    	            	android:id="@+id/text_view_garage"
    	            	android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	            	android:text="@string/garage" />
    	        </LinearLayout>
    			<LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<EditText
    	            	android:id="@+id/garage_edit"
    	            	android:layout_width="wrap_content"
    	            	android:layout_height="wrap_content"
    	            	android:layout_gravity="right"
    	            	android:layout_marginRight="45dp"
    	            	android:ems="5"
    	            	android:inputType="number"
    	            	android:textSize="12sp" />
    	        </LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 5eme ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    			<LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<TextView
    	            	android:id="@+id/text_view_piece"
    	            	android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	            	android:text="@string/piece" />
    			</LinearLayout>
    			<LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<EditText
    	            	android:id="@+id/piece_edit"
    	            	android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:layout_gravity="right"
    	                android:layout_marginRight="45dp"
    	            	android:ems="5"
    	            	android:inputType="number"
    	            	android:textSize="12sp" />
    	    	</LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 6eme ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    			<LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<TextView
    	            	android:id="@+id/text_view_chambre"
    	            	android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	            	android:text="@string/chambre" />
    			</LinearLayout>
    			<LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<EditText
    	            	android:id="@+id/chambre_edit"
    	            	android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:layout_gravity="right"
    	                android:layout_marginRight="45dp"
    	            	android:ems="5"
    	            	android:inputType="number"
    	            	android:textSize="12sp" />
    	    	</LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 7eme ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    			<LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<TextView
    	            	android:id="@+id/text_view_park_int"
    	            	android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	            	android:text="@string/park_int" />
    			</LinearLayout>
    			<LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<EditText
    	            	android:id="@+id/park_int_edit"
    	            	android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:layout_gravity="right"
    	                android:layout_marginRight="45dp"
    	            	android:ems="5"
    	            	android:inputType="number"
    	            	android:textSize="12sp" />
    	        </LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 8eme ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    			<LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<TextView
    	            	android:id="@+id/text_view_park_ext"
    	            	android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	            	android:text="@string/park_ext" />
    			</LinearLayout>
    			<LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<EditText
    	            	android:id="@+id/park_ext_edit"
    	                android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:layout_gravity="right"
    	                android:layout_marginRight="45dp"
    	            	android:ems="5"
    	            	android:inputType="number"
    	            	android:textSize="12sp" />
    	    	</LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 9eme ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    			<LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<TextView
    	            	android:id="@+id/text_view_sdb"
    	                android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	            	android:text="@string/sdb" />
    	        </LinearLayout>
    			<LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<EditText
    	            	android:id="@+id/sdb_edit"
    	                android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:layout_gravity="right"
    	                android:layout_marginRight="45dp"
    	            	android:ems="5"
    	            	android:inputType="number"
    	            	android:textSize="12sp" />
    	    	</LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 10eme ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    			<LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<TextView
    	            	android:id="@+id/text_view_sd"
    	                android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	            	android:text="@string/sd" />
    			</LinearLayout>
    	        <LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<EditText
    	            	android:id="@+id/sd_edit"
    	                android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:layout_gravity="right"
    	                android:layout_marginRight="45dp"
    	            	android:ems="5"
    	            	android:inputType="number"
    	            	android:textSize="12sp" />
    	    	</LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 11eme ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    			<LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<TextView
    	            	android:id="@+id/text_view_ch_rdc"
    	                android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	            	android:text="@string/ch_rdc" />
    			</LinearLayout>
    	        <LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<EditText
    	            	android:id="@+id/ch_rdc_edit"
    	                android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:layout_gravity="right"
    	                android:layout_marginRight="45dp"
    	            	android:ems="5"
    	            	android:inputType="number"
    	            	android:textSize="12sp" />
    	    	</LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 12eme ligne = texte + champs editable -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    			<LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<TextView
    	            	android:id="@+id/text_view_etage"
    	                android:layout_width="0dp"
    	                android:layout_height="match_parent"
    	                android:layout_gravity="center_vertical"
    	                android:layout_marginLeft="5dp"
    	                android:layout_weight="1"
    	                android:gravity="center"
    	            	android:text="@string/etage" />
    			</LinearLayout>
    	        <LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<EditText
    	            	android:id="@+id/etage_edit"
    	                android:layout_width="wrap_content"
    	                android:layout_height="wrap_content"
    	                android:layout_gravity="right"
    	                android:layout_marginRight="45dp"
    	            	android:ems="5"
    	            	android:inputType="number"
    	            	android:textSize="12sp" />
    	    	</LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 13eme ligne = check box -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_weight="1"
    	        android:orientation="horizontal" >
    	        <LinearLayout
    	            android:layout_width="wrap_content"
    	            android:layout_height="match_parent"
    	            android:layout_gravity="center"
    	            android:gravity="center"
    	            android:orientation="horizontal" >
    	        	<CheckBox
    	            	android:id="@+id/check_box_plain_pied"
    	            	android:layout_width="wrap_content"
    	            	android:layout_height="wrap_content"
    	            	android:layout_marginLeft="10dp"
    	            	android:text="@string/plain_pied" />
    	        </LinearLayout>
    	        <LinearLayout
    	            android:layout_width="match_parent"
    	            android:layout_height="wrap_content"
    	            android:layout_gravity="center"
    	            android:gravity="right"
    	            android:orientation="horizontal" >
    	        	<CheckBox
    	            	android:id="@+id/check_box_sur_sous_sol"
    	            	android:layout_width="wrap_content"
    	            	android:layout_height="wrap_content"
    	            	android:layout_marginRight="10dp"
    	            	android:text="@string/sur_sous_sol" />
    	        </LinearLayout>
    	    </LinearLayout>
     
    	    <!-- 14eme ligne = texte -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_gravity="left"
    	        android:layout_weight="1"
    	        android:gravity="center"
    	        android:orientation="horizontal" >
    	        <TextView
    	            android:id="@+id/text_view_titre_cuisine"
    	            android:layout_width="wrap_content"
    	            android:layout_height="wrap_content"
    	            android:text="@string/cuisine" />
    	    </LinearLayout>
     
    	    <!-- 15eme ligne = grid view -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="match_parent"
    	        android:layout_gravity="left"
    	        android:layout_weight="1"
    	        android:gravity="center"
    	        android:orientation="horizontal" >
    	        <GridView
    	            android:id="@+id/liste_cuisine"
    	            android:layout_width="match_parent"
    	            android:layout_height="match_parent"
    	            android:choiceMode="multipleChoice"
    	            android:entries="@array/liste_cui"
    	            android:gravity="center"
    	            android:numColumns="auto_fit"
    	            android:stretchMode="columnWidth"
    	            android:textSize="8sp" />
    	    </LinearLayout>
     
    	    <!-- 16eme ligne = texte -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_gravity="left"
    	        android:layout_weight="1"
    	        android:gravity="center"
    	        android:orientation="horizontal" >
    	        <TextView
    	            android:id="@+id/text_view_titre_type_chauff"
    	            android:layout_width="wrap_content"
    	            android:layout_height="wrap_content"
    	            android:text="@string/type_chauff" />
    	    </LinearLayout>
     
    	    <!-- 17eme ligne = grid view -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="match_parent"
    	        android:layout_gravity="left"
    	        android:layout_weight="1"
    	        android:gravity="center"
    	        android:orientation="horizontal" >
    	        <GridView
    	            android:id="@+id/liste_chauff"
    	            android:layout_width="match_parent"
    	            android:layout_height="match_parent"
    	            android:choiceMode="multipleChoice"
    	            android:entries="@array/liste_type_chauff"
    	            android:gravity="center"
    	            android:numColumns="auto_fit"
    	            android:stretchMode="columnWidth"
    	            android:textSize="12sp" />
    	    </LinearLayout>
     
    	    <!-- 18eme ligne = texte -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_gravity="left"
    	        android:layout_weight="1"
    	        android:gravity="center"
    	        android:orientation="horizontal" >
    	        <TextView
    	            android:id="@+id/text_view_titre_nat_chauff"
    	            android:layout_width="wrap_content"
    	            android:layout_height="wrap_content"
    	            android:text="@string/nature_chauff" />
    	    </LinearLayout>
     
    	    <!-- 19eme ligne = spinner -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_gravity="left"
    	        android:layout_weight="1"
    	        android:gravity="center"
    	        android:orientation="horizontal" >
    	        <Spinner
    	            android:id="@+id/spinner_nat_chauff"
    	            android:layout_width="wrap_content"
    	            android:layout_height="wrap_content"
    	            android:prompt="@string/chauffage" />
    	    </LinearLayout>
     
    	    <!-- 20eme ligne = bouton -->
    	    <LinearLayout
    	        android:layout_width="match_parent"
    	        android:layout_height="0dp"
    	        android:layout_gravity="left"
    	        android:layout_weight="1"
    	        android:gravity="center"
    	        android:orientation="horizontal" >
    	        <Button
    	            android:id="@+id/buttonSaveIntBien"
    	            android:layout_width="wrap_content"
    	            android:layout_height="wrap_content"
    	            android:layout_marginBottom="5dp"
    	            android:text="@string/save" />
    	    </LinearLayout>
    	</LinearLayout>
    </ScrollView>
    Un grand merci à vous deux pour votre aide !!!

    Maintenant, il reste encore mon problème des GridView... Je suis vraiment coincé :/ Personne n'aurait une idée ??

  5. #5
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Janvier 2014
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2014
    Messages : 7
    Points : 5
    Points
    5
    Par défaut
    Salut les amis,

    Je viens enfin de résoudre mon problème de GridView !!
    Après plusieurs recherchent, on m'a conseillé de "re-coder" GridView et c'est ce que j'ai fait.
    Voici le code de la classe GridView:
    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.example.testpositionnement;
     
    import android.content.Context;
    import android.util.AttributeSet;
    import android.widget.GridView;
     
    public class MyGridView extends GridView {
        public MyGridView(Context context) {
            super(context);
        }
     
        public MyGridView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
     
        public MyGridView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
     
        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int heightSpec;
     
            if (getLayoutParams().height == LayoutParams.WRAP_CONTENT) {
                // The great Android "hackatlon", the love, the magic.
                // The two leftmost bits in the height measure spec have
                // a special meaning, hence we can't use them to describe height.
                heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
            }
            else {
                // Any other height should be respected as is.
                heightSpec = heightMeasureSpec;
            }
     
            super.onMeasure(widthMeasureSpec, heightSpec);
        }
    }
    Et voici mon implémentation de MyGridView dans mon Activity:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    myGridView1 = (MyGridView) findViewById(R.id.liste_cuisine);
    elements1 = getResources().getStringArray(R.array.liste_cui);
    ArrayList<String> label1 = new ArrayList<String>();
    for (int i=0; i < elements1.length; i++) {
    	label1.add(elements1[i]);
    }
    ArrayAdapter<String> adaptateur1 = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, label1);
    myGridView1.setAdapter(adaptateur1);
    myGridView1.setOnItemClickListener(new OnItemClickListener() {
    	public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    		Toast.makeText(MainActivity.this, "L'element selectionne est >"+elements1[position]+"<", Toast.LENGTH_SHORT).show();
    	}
    });
    Grâce à cela, j'ai bien MyGridView qui est affiché en entier dans mon Activity.
    En tout cas, un grand merci à vous, Eazer et Hizin !!!

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

Discussions similaires

  1. problème de mise en page
    Par cyrill.gremaud dans le forum ASP
    Réponses: 10
    Dernier message: 29/08/2005, 15h54
  2. problème de mise en page d'une zone de liste
    Par audrey_desgres dans le forum Access
    Réponses: 26
    Dernier message: 24/06/2005, 09h11
  3. [PostScript] Problème de mise en page
    Par gege2061 dans le forum Autres langages
    Réponses: 4
    Dernier message: 29/04/2005, 16h07
  4. Problème de mise en page
    Par Pill_S dans le forum Mise en page CSS
    Réponses: 8
    Dernier message: 11/01/2005, 18h35
  5. [CR]Problème de mise en page
    Par CaramelChoca dans le forum SAP Crystal Reports
    Réponses: 1
    Dernier message: 16/12/2004, 10h16

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