I have a ListView that retrieves data from my SQLite database. I am wanting the record at the top to be a different colour (green for e.g) and the record at the bottom to be something else entirely (red for e.g).
public ListAdapter generateLocal(Context context) {
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
int position = 1;
for (LeaugeTable jb : db.sqlite().getLeaugeTable(divisonName)) {
HashMap<String, String> jobValues = new HashMap<String, String>();
jb.setPosition(position);
position++;
if (jb.getPosition() == 1) {
} else if (jb.getPosition() == 2 || jb.getPosition() == 3 || jb.getPosition() == 4 || jb.getPosition() == 5) {
} else if (jb.getPosition() == 24 || jb.getPosition() == 23 || jb.getPosition() == 22) {
}
jobValues.put("pos", String.valueOf(jb.getPosition()));
jobValues.put("name", jb.getName());
jobValues.put("played", String.valueOf(jb.getPlayed()));
jobValues.put("gfor", String.valueOf(jb.getGoalsFor()));
jobValues.put("gagainst", String.valueOf(jb.getGoalsAgainst()));
jobValues.put("gdiff", String.valueOf(jb.getGoalDifference()));
jobValues.put("points", String.valueOf(jb.getPoints()));
mylist.add(jobValues);
}
return new SimpleAdapter(context, mylist, R.layout.leauge, new String[]{
"pos", "name", "played", "gfor", "gagainst", "gdiff", "points"},
new int[]{R.id.team_position, R.id.team_name, R.id.team_pj,
R.id.team_gf, R.id.team_ga, R.id.team_dif,
R.id.team_pts});
}
Aucun commentaire:
Enregistrer un commentaire