0

I'm having some issues inflating some views. I have an arraylist with objects of Events. The events has got their individual layouts. If two events has got the same date I want to combine them in a layout and then I want to add all events to a new arraylist. This is my start:

ArrayList<Event> events = getEventlist();
ArrayList<View> eventListWithDates = new ArrayList<View>();
    for(int i = 0; i < events.size(); i++){
        String date1 = "0";
        String date2 = "1";
        if(i != 0){
            date1 = events.get(i-1).getDate();
            date2 = events.get(i).getDate();
        }
        if(date1.equals(date2)){
            /* This is where I need your help.
                How do I add the current event to the last eventView? */
        } else {
            View view = getLayoutInflater().inflate(R.layout.datehead, calendarLayout, false);
            LinearLayout eventView = (LinearLayout) findViewById(R.id.eventView);
            eventView.addView(events.get(i).getEvent());
            eventListWithDates.add(view);
        }
    }

Hope you understood what I want to do. Any ideas?

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
jahed
  • 171
  • 12
  • you can get the previous event view in a similar fashion you get the previous event date, as it is in the eventListWithDates array (last position), then, identically, you fetch the linearlayout and add your view to it. – njzk2 Feb 20 '14 at 17:11
  • Do you mean like this: View view = eventListWithDates.get(eventListWithDates.size()-1); LinearLayout eventView = (LinearLayout) findViewById(R.id.eventView); eventView.addView(events.get(i).getEvent()); Will that really work? – jahed Feb 20 '14 at 17:49

0 Answers0