Problème adaptation ListView
Bonjour,
J'ai une requête qui séléctionne par nom un client, et l'intégrer donc dans une ListView avec un arrayAdapter. Seulement, je suis embêté puisque si 2 (voire plus) clients portent le même nom, seul un s'affiche..
Je pense avoir ciblé le problème ce serait cette fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public client cursorToClient(Cursor c) {
if (c.getCount() == 0) {
return null;
}
c.moveToFirst();
client cli = new client();
cli.setId(c.getInt(NUM_COL_ID));
cli.setNom(c.getString(NUM_COL_NOM));
cli.setPrenom(c.getString(NUM_COL_PRENOM));
cli.setAdresse(c.getString(NUM_COL_ADRESSE));
cli.setCp(c.getString(NUM_COL_CP));
cli.setVille(c.getString(NUM_COL_VILLE));
cli.setMail(c.getString(NUM_COL_MAIL));
cli.setTel(c.getString(NUM_COL_TEL));
cli.setNbpizzaencours(c.getInt(NUM_COL_PIZZAENCOURS));
cli.setNbpizzatotal(c.getInt(NUM_COL_PIZZATOTAL));
c.close();
return cli;
} |
Mon Curseur va à la première ligne mais c'est tout, seulement je vois pas comment faire pour l'adapter, et qu'elle me retourne plusieurs clients..
J'ai bien tenté :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public client cursorToClient(Cursor c) {
if (c.getCount() == 0) {
return null;
}
for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
client cli = new client();
cli.setId(c.getInt(NUM_COL_ID));
cli.setNom(c.getString(NUM_COL_NOM));
cli.setPrenom(c.getString(NUM_COL_PRENOM));
cli.setAdresse(c.getString(NUM_COL_ADRESSE));
cli.setCp(c.getString(NUM_COL_CP));
cli.setVille(c.getString(NUM_COL_VILLE));
cli.setMail(c.getString(NUM_COL_MAIL));
cli.setTel(c.getString(NUM_COL_TEL));
cli.setNbpizzaencours(c.getInt(NUM_COL_PIZZAENCOURS));
cli.setNbpizzatotal(c.getInt(NUM_COL_PIZZATOTAL));
return cli;}
c.close();
} |
Si quelqu'un a une solution..
Merci d'avance :)