Salut
J'aimerai organiser l'affichage de ma liste comme une expandableListView puisque j'ai besoin de l'affichage juste du libellé du centre de formation et son adresse et lorsque l'utilisateur clique sur un "groupe" les autres informations s'affichent. cependant les groupes de mon expandableListe sont récupéré de la base de données et je n'ai pas su comment faire pour associer seulement le libellé et l'adresse pour chaque groupe et laisser les autres informations pour les enfants du groupe.
Que dois je utiliser une Liste?? j'ai essayé de récupérer les données sous forme de liste mais le problème je n'ai pas su comment récupérer les infos de chaque élément de la liste, càd getLibellé() par exemple.
Avez vous une proposition?
merci
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 public List recupererListe(String ville, String catégorie){ List formations = new ArrayList(); Cursor c = bdd.query(TABLE_FORMATION, new String[] {COL_ID, COL_LIB, COL_TEL, COL_EMAIL, COL_ADR, COL_VILLE, COL_CAT}, COL_VILLE + " LIKE ? and " + COL_CAT + " LIKE ?", new String[] { ville, catégorie }, null, null, null); c.moveToFirst(); while (!c.isAfterLast()) { formations.add(cursorToFormation(c)); c.moveToNext(); } c.close(); return formations; }
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 GroupeFormation { private String nomCentreFormation; private String adresse; private ArrayList<InfosCentre> détails; public GroupeFormation(String libellé, String adresse){ super(); this.nomCentreFormation = libellé; this.adresse = adresse; this.détails = new ArrayList<InfosCentre>(); } public void setGroupeFormation(String groupeFormation) { this.nomCentreFormation = groupeFormation; } public String getGroupeFormation() { return nomCentreFormation; } public void setAdresse(String adresse) { this.adresse = adresse; } public String getAdresse() { return adresse; } public void setDétails(ArrayList<InfosCentre> détails) { this.détails = détails; } public ArrayList<InfosCentre> getDétails() { return détails; } }
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 public class InfosCentre { private GroupeFormation centreDeFormation; private String email; private String tel; private String catégorie; public InfosCentre(GroupeFormation centre, String email, String tel, String catégorie){ super(); this.centreDeFormation = centre; this.email = email; this.tel = tel; this.catégorie = catégorie; } public void setCentreDeFormation(GroupeFormation centreDeFormation) { this.centreDeFormation = centreDeFormation; } public GroupeFormation getCentreDeFormation() { return centreDeFormation; } public void setEmail(String email) { this.email = email; } public String getEmail() { return email; } public void setTel(String tel) { this.tel = tel; } public String getTel() { return tel; } public void setCatégorie(String catégorie) { this.catégorie = catégorie; } public String getCatégorie() { return catégorie; } }
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 public class CentreAdapter extends Activity { FormationBDD formationBdd; private ExpandableListView expandableList = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main2); expandableList = (ExpandableListView) findViewById(R.id.expandableView); ArrayList<GroupeFormation> groupes = new ArrayList<GroupeFormation>(); String ville = "ville"; String catégorie = "catégorie"; List list = formationBdd.recupererListe(ville, catégorie); for(int i = 0; i < list.size(); i++){ ListIterator iterator = list.listIterator(); while(iterator.hasNext()){ GroupeFormation centre = new GroupeFormation() // comment récupérer le nom de l'élement i } } } }
Partager