Bonjour.

Je suis débutant sous la programmation Android et je développe actuellement une application dans le cadre de mon stage de fin d'étude.
Cette application a pour but de permettre d'écrire et de lire des informations provenant d'une BDD externe concernant la gestion de projets de l'entreprise. Mais cela n'a pas d'importance à la vue de mon problème.

Ce que je cherche à faire pour le moment c'est créer une ListView dynamique qui permet d'afficher une suite d'information par élément au même titre que des contacts téléphonique :

NOM 1
Prénom 1
Num 1
-------
NOM 2
Prénom 2
Num 2
...

L'image ci dessous représente ce que je souhaiterais obtenir.

Nom : Screenshot_2014-03-21-12-51-333.png
Affichages : 961
Taille : 49,7 Ko


Le problème c'est que j'affiche bien plusieurs informations mais c'est 2 fois la même, par exemple :

NOM 1
Num 1
Num 1
-------
NOM 2
Num 2
Num 2
...

Il me manque l'info du milieu (Prénom). Voilà ce que j'ai :

Nom : Screenshot_2014-03-21-12-51-33.png
Affichages : 841
Taille : 43,9 Ko

Voici mon code 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
 
public class ListSample extends Activity {  
 
    public final static String ITEM_TITLE = "title";  
    public final static String ITEM_CAPTION1 = "caption";  
    public final static String ITEM_CAPTION2 = "caption"; 
 
    public Map<String,?> createItem(String title, String caption1, String caption2) {  
        Map<String,String> item = new HashMap<String,String>();  
        item.put(ITEM_TITLE, title);  
        item.put(ITEM_CAPTION1, caption1); 
        item.put(ITEM_CAPTION2, caption2);
        return item;  
    }  
 
    @Override  
    public void onCreate(Bundle icicle) {  
        super.onCreate(icicle);  
 
        List<Map<String,?>> security = new LinkedList<Map<String,?>>();  
        security.add(createItem("TITRE 1", "Info 1", "Info 2"));  
        security.add(createItem("TITRE 2", "Info 1","Info 2"));  
        security.add(createItem("TITRE 3", "Info 1", "Info 2"));
 
 
        // create our list and custom adapter  
        SeparatedListAdapter adapter = new SeparatedListAdapter(this);  
        //adapter.addSection("Array test", new ArrayAdapter<String>(this,  
          //  R.layout.list_item, new String[] { "First item", "Item two" }));  
        adapter.addSection("Liste des tickets", new SimpleAdapter(this, security, R.layout.list_complex,   
            new String[] { ITEM_TITLE, ITEM_CAPTION1, ITEM_CAPTION2 }, new int[] { R.id.list_complex_title, R.id.list_complex_caption1, R.id.list_complex_caption2 }));  
 
        ListView list = new ListView(this);  
        list.setAdapter(adapter);  
        this.setContentView(list);  
 
    }  
 
}
Et ici mon adaptateur de la ListView :

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
 
public class SeparatedListAdapter extends BaseAdapter {  
 
    public final Map<String,Adapter> sections = new LinkedHashMap<String,Adapter>();  
    public final ArrayAdapter<String> headers;  
    public final static int TYPE_SECTION_HEADER = 0;  
 
    public SeparatedListAdapter(Context context) {  
        headers = new ArrayAdapter<String>(context, R.layout.list_header);  
    }  
 
    public void addSection(String section, Adapter adapter) {  
        this.headers.add(section);  
        this.sections.put(section, adapter);  
    }  
 
    public Object getItem(int position) {  
        for(Object section : this.sections.keySet()) {  
            Adapter adapter = sections.get(section);  
            int size = adapter.getCount() + 1;  
 
            // check if position inside this section   
            if(position == 0) return section;  
            if(position < size) return adapter.getItem(position - 1);  
 
            // otherwise jump into next section  
            position -= size;  
        }  
        return null;  
    }  
 
    public int getCount() {  
        // total together all sections, plus one for each section header  
        int total = 0;  
        for(Adapter adapter : this.sections.values())  
            total += adapter.getCount() + 1;  
        return total;  
    }  
 
    public int getViewTypeCount() {  
        // assume that headers count as one, then total all sections  
        int total = 1;  
        for(Adapter adapter : this.sections.values())  
            total += adapter.getViewTypeCount();  
        return total;  
    }  
 
    public int getItemViewType(int position) {  
        int type = 1;  
        for(Object section : this.sections.keySet()) {  
            Adapter adapter = sections.get(section);  
            int size = adapter.getCount() + 1;  
 
            // check if position inside this section   
            if(position == 0) return TYPE_SECTION_HEADER;  
            if(position < size) return type + adapter.getItemViewType(position - 1);  
 
            // otherwise jump into next section  
            position -= size;  
            type += adapter.getViewTypeCount();  
        }  
        return -1;  
    }  
 
    public boolean areAllItemsSelectable() {  
        return false;  
    }  
 
    public boolean isEnabled(int position) {  
        return (getItemViewType(position) != TYPE_SECTION_HEADER);  
    }  
 
    @Override  
    public View getView(int position, View convertView, ViewGroup parent) {  
        int sectionnum = 0;  
        for(Object section : this.sections.keySet()) {  
            Adapter adapter = sections.get(section);  
            int size = adapter.getCount() + 1;  
 
            // check if position inside this section   
            if(position == 0) return headers.getView(sectionnum, convertView, parent);  
            if(position < size) return adapter.getView(position - 1, convertView, parent);  
 
            // otherwise jump into next section  
            position -= size;  
            sectionnum++;  
        }  
        return null;  
    }  
 
    @Override  
    public long getItemId(int position) {  
        return position;  
    }  
 
}
J'espère avoir été suffisamment précis. J'ai déjà mon idée que le problème concerne probablement le map<String,?>, mais étant débutant, je peine à comprendre son fonctionnement et donc à résoudre le problème.
Merci d'avance.