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