Bonjour

Une simple application avec un spinner contenant 30 items quand je lance et clique sur le spinner qui apparait sur l'emulateur il faut attendre plus de 10 secondes pour l'ouvrir
aussi pour choisir un item

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
 package com.example.shayw.spinnerapp;
 
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.AdapterView.OnItemSelectedListener;
 
public class MainActivity extends Activity {
 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        Spinner staticSpinner = (Spinner) findViewById(R.id.static_spinner);
        String[] items = new String[]{
                "Item1",
                "Item2",
                "Item3",
                "Item4",
                "Item5",
                "Item6",
                "Item7",
                "Item8",
                "Item9",
                "Item10",
                "Item11",
                "Item12",
                "Item13",
                "Item14",
                "Item15",
                "Item16",
                "Item17",
                "Item18",
                "Item19",
                "Item20",
                "Item21",
                "Item22",
                "Item23",
                "Item24",
                "Item25",
                "Item26",
                "Item27",
                "Item28",
                "Item29",
                "Item30",
                "Item31",
        };
        ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(
                this,R.layout.support_simple_spinner_dropdown_item,items
        );
 
        // Specify the layout to use when the list of choices appears
        spinnerArrayAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
        staticSpinner.setAdapter(spinnerArrayAdapter);
 
        // Apply the adapter to the spinner
 
 
 
        staticSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
            @Override
 
            public void onItemSelected(AdapterView<?> parent, View view,
                                       int position, long id) {
                Log.v("item", (String) parent.getItemAtPosition(position));
            }
 
            @Override
            public void onNothingSelected(AdapterView<?> parent) {
                // TODO Auto-generated method stub
            }
        });
    }
}
et le 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
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
 
    <Spinner
        android:id="@+id/static_spinner"
        android:layout_width= "wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="20dp"
        android:layout_marginStart="20dp" />
 
</RelativeLayout>

Merci d'avance