import java.util.Date;
import android.content.Context;
-import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
-import android.widget.ImageView;
import android.widget.TextView;
public class EventAdapter extends ArrayAdapter<Event> {
private final Event[] values;
private final Context context;
- public EventAdapter(Context context,Event[] values) {
+
+ public EventAdapter(final Context context, final Event[] values) {
super(context,R.layout.event_row_layout,values);
this.context=context;
this.values=values;
}
@Override
- public View getView(int position, View convertView, ViewGroup parent) {
- LayoutInflater inflater = (LayoutInflater) context
+ public View getView(final int position, final View convertView, final ViewGroup parent) {
+ final LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View rowView = inflater.inflate(R.layout.event_row_layout, parent, false);
- TextView title = (TextView) rowView.findViewById(R.id.smalleventtitle);
- TextView dstart = (TextView) rowView.findViewById(R.id.smalldatestart);
- TextView dend = (TextView) rowView.findViewById(R.id.smalldateend);
- ImageView header = (ImageView) rowView.findViewById(R.id.rowHeader);
+ final View rowView = inflater.inflate(R.layout.event_row_layout, parent, false);
+ final TextView title = (TextView) rowView.findViewById(R.id.smalleventtitle);
+ final TextView dstart = (TextView) rowView.findViewById(R.id.smalldatestart);
+ final TextView dend = (TextView) rowView.findViewById(R.id.smalldateend);
+ final View header = rowView.findViewById(R.id.rowHeader);
header.setBackgroundColor(values[position].eventColour);
title.setText(values[position].title);
dstart.setText(new Date(values[position].dtstart).toString());
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
- public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
- long arg3) {
- // TODO Auto-generated method stub
+ public void onItemClick(final AdapterView<?> arg0, final View arg1, final int arg2,
+ final long arg3) {
DisplayEventActivity.displayEvent(EventListActivity.this,events[arg2]);
}