package com.example.android.sunshine.app;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class ForecastAdapter extends CursorAdapter {

    public ForecastAdapter(Context context, Cursor c, int flags) {
        super(context, c, flags);
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.list_item_forecast, parent, false);
        return view;
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        ImageView iconView = (ImageView) view.findViewById(R.id.list_item_icon);
        TextView dateView = (TextView) view.findViewById(R.id.list_item_date_textview);
        TextView forecastView = (TextView) view.findViewById(R.id.list_item_forecast_textview);
        TextView highView = (TextView) view.findViewById(R.id.list_item_high_textview);
        TextView lowView = (TextView) view.findViewById(R.id.list_item_low_textview);

        int iconId = cursor.getInt(MainFragment.COL_WEATHER_ID);
        double high = cursor.getDouble(MainFragment.COL_WEATHER_MAX_TEMP);
        double low = cursor.getDouble(MainFragment.COL_WEATHER_MIN_TEMP);
        String forecast = cursor.getString(MainFragment.COL_WEATHER_DESC);
        long dateInMillis = cursor.getLong(MainFragment.COL_WEATHER_DATE);

        boolean isMetric = Utility.isMetric(context);

        iconView.setImageResource(R.drawable.ic_launcher);
        dateView.setText(Utility.formatDate(dateInMillis));
        forecastView.setText(forecast);
        highView.setText(Utility.formatTemperature(high, isMetric));
        lowView.setText(Utility.formatTemperature(low, isMetric));
    }
}
@@ -361,16 +361,108 @@
 pter %7B%0A%0A
+    private final int VIEW_TYPE_TODAY = 0;%0A    private final int VIEW_TYPE_FUTURE_DAY = 1;%0A%0A
     publ
@@ -663,84 +663,375 @@
     
-View view = LayoutInflater.from(context).inflate(R.layout.list_item_forecast
+int viewType = getItemViewType(cursor.getPosition());%0A%0A        int layoutId = -1;%0A%0A        if (viewType == VIEW_TYPE_TODAY) %7B%0A            layoutId = R.layout.list_item_forecast_today;%0A        %7D else if (viewType == VIEW_TYPE_FUTURE_DAY) %7B%0A            layoutId = R.layout.list_item_forecast;%0A        %7D%0A%0A        View view = LayoutInflater.from(context).inflate(layoutId
 , pa
@@ -1044,16 +1044,17 @@
 false);%0A
+%0A
         
@@ -2317,10 +2317,226 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public int getViewTypeCount() %7B%0A        return 2;%0A    %7D%0A%0A    @Override%0A    public int getItemViewType(int position) %7B%0A        return (position == 0) ? VIEW_TYPE_TODAY : VIEW_TYPE_FUTURE_DAY;%0A    %7D
 %0A%7D

Use two different view types with ForecastAdapter