@Override
  public View getView(int position, View view, ViewGroup parent) {
    ViewHolder viewHolder;
    if (view == null) {
      view = layoutInflater.inflate(R.layout.events_item, null);
      viewHolder = new ViewHolder();
      viewHolder.name = (TextView) view.findViewById(R.id.event_title);
      viewHolder.price = (TextView) view.findViewById(R.id.event_price);
      viewHolder.place = (TextView) view.findViewById(R.id.event_place);
      viewHolder.time = (TextView) view.findViewById(R.id.event_time);
      viewHolder.icon = (ImageView) view.findViewById(R.id.event_image);
      view.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) view.getTag();
    }
    EventItem item = getItem(position);

    /** Sets the icon. */
    int iconRes = 0;
    String category = item.getCategoryID();
    if (category.equals("SPORT")) iconRes = (R.drawable.category_sport);
    else if (category.equals("PERFORMANCES")) iconRes = (R.drawable.category_performances);
    else if (category.equals("MUSIC")) iconRes = (R.drawable.category_music);
    else if (category.equals("EXHIBITIONS")) iconRes = (R.drawable.category_exhibitions);
    else if (category.equals("NIGHTLIFE")) iconRes = (R.drawable.category_nightlife);
    else if (category.equals("PRESENTATIONS")) iconRes = (R.drawable.category_presentations);
    else if (category.equals("DEBATE")) iconRes = (R.drawable.category_debate);
    else if (category.equals("OTHER")) iconRes = (R.drawable.category_other);
    viewHolder.icon.setImageResource(iconRes);

    /** Sets the rest of the fields. */
    viewHolder.name.setText(item.getTitle());
    viewHolder.place.setText(item.getPlaceName());
    SimpleTimeFormat time = new SimpleTimeFormat(item.getDateStart());
    viewHolder.time.setText(time.getUserTimeDate());
    String free = getContext().getString(R.string.free);
    String cost = item.getPrice() <= 0 ? free : ((int) item.getPrice()) + " kr";
    viewHolder.price.setText(cost);

    return view;
  }