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