| 1 | package ro.ieval.unical; |
| 2 | import java.util.Date; |
| 3 | |
| 4 | import android.content.Context; |
| 5 | import android.graphics.Color; |
| 6 | import android.view.LayoutInflater; |
| 7 | import android.view.View; |
| 8 | import android.view.ViewGroup; |
| 9 | import android.widget.ArrayAdapter; |
| 10 | import android.widget.ImageView; |
| 11 | import android.widget.TextView; |
| 12 | |
| 13 | |
| 14 | public class EventAdapter extends ArrayAdapter<Event> { |
| 15 | private final Event[] values; |
| 16 | private final Context context; |
| 17 | public EventAdapter(Context context,Event[] values) { |
| 18 | super(context,R.layout.event_row_layout,values); |
| 19 | this.context=context; |
| 20 | this.values=values; |
| 21 | } |
| 22 | |
| 23 | @Override |
| 24 | public View getView(int position, View convertView, ViewGroup parent) { |
| 25 | LayoutInflater inflater = (LayoutInflater) context |
| 26 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| 27 | View rowView = inflater.inflate(R.layout.event_row_layout, parent, false); |
| 28 | TextView title = (TextView) rowView.findViewById(R.id.smalleventtitle); |
| 29 | TextView dstart = (TextView) rowView.findViewById(R.id.smalldatestart); |
| 30 | TextView dend = (TextView) rowView.findViewById(R.id.smalldateend); |
| 31 | ImageView header = (ImageView) rowView.findViewById(R.id.rowHeader); |
| 32 | header.setBackgroundColor(values[position].eventColour); |
| 33 | title.setText(values[position].title); |
| 34 | dstart.setText(new Date(values[position].dtstart).toString()); |
| 35 | dend.setText(new Date(values[position].dtend).toString()); |
| 36 | |
| 37 | return rowView; |
| 38 | } |
| 39 | } |