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
| flightList = (ListView) findViewById(R.id.flightList);
ArrayList<Flight> myFlights = new ArrayList<Flight>();
myFlights.add(new Flight("BLABLA1","TOTO1",System.currentTimeMillis()));
myFlights.add(new Flight("BLABLA2","TOTO2",System.currentTimeMillis()));
//Concept de SingleAdapter du SDZ
String[][] repertoire = new String[myFlights.size()][3];
for (int i=0; i<myFlights.size(); i++)
{
repertoire[i][0]=myFlights.get(i).getReference();
repertoire[i][1]=myFlights.get(i).getLastname();
repertoire[i][2]=""+myFlights.get(i).getDate();
}
List<HashMap<String, String>> liste = new ArrayList<HashMap<String, String>>();
HashMap<String, String> element;
for(int i = 0 ; i < repertoire.length ; i++)
{
element = new HashMap<String, String>();
element.put("text1", repertoire[i][0]);
element.put("text2", repertoire[i][1]);
liste.add(element);
}
ListAdapter adapter = new SimpleAdapter(this, liste, android.R.layout.simple_list_item_2, new String[] {"text1", "text2"}, new int[] {android.R.id.text1, android.R.id.text2 });
flightList.setAdapter(adapter); |
Partager