Jeg ville egentlig gerne have vist navn og dato for sig i hver sin kolonne i listview.
Jeg har forsøgt mig med denne kode, men den fejler:
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
-
- ListView myListView = (ListView)findViewById(R.id.myListView);
- ArrayList<Event> myEvents = new ArrayList<Event>();
- Event test = new Event();
- myEvents.add(new Event("Niels", test.getDaysBetween("2014/04/18")));
- myEvents.add(new Event("Ejnar", test.getDaysBetween("2014/05/28")));
- myEvents.add(new Event("Viggo", test.getDaysBetween("2014/11/25")));
- myEvents.add(new Event("Anette", test.getDaysBetween("2014/08/13")));
-
- String tekst = test.toString1();
- final ArrayAdapter<Event> aa;
-
-
- aa = new ArrayAdapter<Event>(this, android.R.layout.simple_list_item_1, myEvents);
-
- myListView.setAdapter(aa);
-
-
-
-
- for (int i=0; i<myEvents.size(); i++){
- myEvents.add(0, myEvents.get(i));
- aa.notifyDataSetChanged();
- }
- }